从添加的数据中获取bindId到ListView(Titanium/Alloy)中的TableView中 [英] Get bindId from added data to an TableView inside a ListView (Titanium/Alloy)
问题描述
我将ListView旋转了-90度,并且将ListItem旋转了90度,内置于Alloy Titanium中.
I've a ListView rotated -90 degrees, with it's ListItem's rotated 90 degrees built in Alloy Titanium.
每个ListItem都有一个标题Label和一个内容TableView,并且TableView数据是动态的.
Each ListItem has a header Label and a content TableView, and the TableView data is dynamic.
这是我的index.xml:
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>
我正在像这样设置每个TableView数据:
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);
问题是当我想获取被点击的行的ID时.
The problem is when I want to get the id of the clicked row.
这是我的itemclick事件(项目索引和表格视图数据):
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
推荐答案
您可以设置
itemId
itemId
为此
这篇关于从添加的数据中获取bindId到ListView(Titanium/Alloy)中的TableView中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!