[ALOY-899] Cannot add/remove class from ListViewItem
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Medium |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2013-12-13T15:16:36.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | n/a |
Labels | n/a |
Reporter | Davide Cassenti |
Assignee | Tony Lukasavage |
Created | 2013-12-13T14:53:41.000+0000 |
Updated | 2014-06-22T13:23:16.000+0000 |
Description
Description
While it is possible to change the style of a ListViewItem by changing the properties one by one (e.g. backgroundColor), it is not possible to useaddClass
, removeClass
or resetClass
to change them by using the classes.
Test code
index.xml
<Alloy autoStyle="true">
<Window>
<ListView id="list" defaultItemTemplate="fullItem" >
<Templates>
<ItemTemplate id="fullItem" name="fullItem" height="88">
<Label bindId="myview" class="firststyle"></Label>
</ItemTemplate>
</Templates>
<ListSection id="section" ></ListSection>
</ListView>
</Window>
</Alloy>
app.tss
".firststyle" : {
backgroundColor:"green"
},
".secondstyle" : {
backgroundColor:"yellow"
}
index.js
$.index.open();
var data = [{
myview : {
text: "One"
}
}, {
myview : {
text : "Two"
}
}];
$.section.setItems(data);
$.list.addEventListener('itemclick', function(e) {
var item = e.section.getItemAt(e.itemIndex);
// item.myview.backgroundColor = "red";
$.resetClass(item.myview, "secondclass");
e.section.updateItemAt(e.itemIndex, item);
});
Note
In the code above, note how changing the color works instead.Comments
- Tony Lukasavage 2013-12-13
As I suspected, Ti.UI.ListItem does not support the
applyProperties()
function, which is critical to the dynamic style application process. I am marking this as "won't fix" as this won't be fixed in Alloy. I do suggest however that this issue be moved to TIMOB and better named to more precisely identify what the problem is here, as a fix in TIMOB for supportingapplyProperties
on ListItems would make this code work automatically in Alloy. Also, you didn't mention the actual error that occurs which identifies the missingapplyProperties
function as the culprit, so please add that before moving it to TIMOB.