从添加的数据中获取 bindId 到 ListView 内的 TableView(钛/合金) [英] Get bindId from added data to an TableView inside a ListView (Titanium/Alloy)

查看:34
本文介绍了从添加的数据中获取 bindId 到 ListView 内的 TableView(钛/合金)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个旋转 -90 度的 ListView,它的 ListItem 在合金钛中旋转了 90 度.

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 事件(项目索引和 tableview 数据):

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

为此

这篇关于从添加的数据中获取 bindId 到 ListView 内的 TableView(钛/合金)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆