问题描述
我已经旋转了-90度,它的ListItem旋转了90度,在合金钛中建造的90度.
每个ListItem都有一个标头标签和一个内容表视图,并且表视图数据是动态的.
这是我的index.xml:
<Alloy> <Window> <ListView id="view" defaultItemTemplate="item"> <Templates> <ItemTemplate id="item" name="item"> <View id="view" bindId="view"> <View class="header"> <Label class="title" bindId="title"/> <Label class="subtitle" bindId="subtitle"/> <Label class="desc" bindId="desc"/> <View class="border"/> </View> <TableView class="content" bindId="content"/> </View> </ItemTemplate> </Templates> <ListSection/> </ListView> </Window> </Alloy>
我正在设置每个桌面数据:
var items = []; items.push({ properties: { backgroundColor: "#fff", width: config.height, height: config.row }, title: { text: "title" }, content: { data: rows //TableViewRow's array } }); $.view.sections[0].setItems(items);
问题是我想获得单击行的ID时.
这是我的ItemClick事件(项目索引和TableView数据):
$.view.addEventListener("itemclick", function(e) { console.log("clicked on item: " + e.itemIndex); var item = $.view.sections[0].getItemAt(e.itemIndex); _.map(item.content.data || [], function(row) { console.log(row); row = null; }); });
有什么方法可以获取单击行的索引?
我尝试将同一事件添加到所有此对象属性中,但仍然没有运气:
item.click item.onclick item.properties.click item.properties.onclick item.content.click item.content.onclick item.content.properties.click item.content.properties.onclick item.events.click item.events.onclick item.properties.events.click item.properties.events.onclick item.content.events.click item.content.events.onclick item.content.properties.events.click item.content.properties.events.onclick
我还尝试将活动侦听器添加到所有行
推荐答案
您可以设置
itemid
为此
问题描述
I've a ListView rotated -90 degrees, with it's ListItem's rotated 90 degrees built in Alloy Titanium.
Each ListItem has a header Label and a content TableView, and the TableView data is dynamic.
This is my index.xml:
<Alloy> <Window> <ListView id="view" defaultItemTemplate="item"> <Templates> <ItemTemplate id="item" name="item"> <View id="view" bindId="view"> <View class="header"> <Label class="title" bindId="title"/> <Label class="subtitle" bindId="subtitle"/> <Label class="desc" bindId="desc"/> <View class="border"/> </View> <TableView class="content" bindId="content"/> </View> </ItemTemplate> </Templates> <ListSection/> </ListView> </Window> </Alloy>
I'm setting each TableView data like this:
var items = []; items.push({ properties: { backgroundColor: "#fff", width: config.height, height: config.row }, title: { text: "title" }, content: { data: rows //TableViewRow's array } }); $.view.sections[0].setItems(items);
The problem is when I want to get the id of the clicked row.
This is my itemclick event (item index and tableview data):
$.view.addEventListener("itemclick", function(e) { console.log("clicked on item: " + e.itemIndex); var item = $.view.sections[0].getItemAt(e.itemIndex); _.map(item.content.data || [], function(row) { console.log(row); row = null; }); });
There is any way to get the index of the clicked row?
I've tried to add that same event to all of this object properties, but still no luck:
item.click item.onclick item.properties.click item.properties.onclick item.content.click item.content.onclick item.content.properties.click item.content.properties.onclick item.events.click item.events.onclick item.properties.events.click item.properties.events.onclick item.content.events.click item.content.events.onclick item.content.properties.events.click item.content.properties.events.onclick
I've also tried to add the event listener to all of the rows
推荐答案
You can set the
itemId
for this