【问题标题】:Get the row id in TableViewRow获取 TableViewRow 中的行 ID
【发布时间】:2015-08-30 12:07:52
【问题描述】:

以下代码在 tableview 中打印“本地”模型,它的工作,现在我的问题是通过单击每一行来获取行 ID 或行详细信息。我已在每一行上附加了 showDetail 函数以获取行详细信息。但无法获取行附加数据。我该如何实现这一点,请帮助我,非常感谢您的回答。

<TableView dataCollection="local">
    <TableViewRow onClick="showDetail">
        <View layout="horizontal">
            <ImageView image="{image}" width="50" height="50"/>
            <Label id="name" text="{title}"></Label>
        </View>
    </TableViewRow>
</TableView>


function showDetail(e){
console.log(e.index);
}

【问题讨论】:

  • 能贴一下showDetail函数的代码吗?
  • 请看我的编辑。什么都没有,我只是控制台 e.index

标签: titanium titanium-alloy


【解决方案1】:

看看 TableView API 点击事件:

http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.TableView-event-click

有所有属性:例如index=行数

看看 rowrowData

【讨论】:

  • 感谢您的回复,我得到了 e 内的索引,但无法通过 e.index 检索。它显示未定义。你能帮帮我吗?
  • 试试 e.rowData[e.index]
  • 刚刚看到您的编辑,尝试将点击事件移动到 tableview,而不是 tableviewrow。
  • 非常感谢非常感谢,我犯了一个非常愚蠢的错误。
猜你喜欢
  • 2012-07-29
  • 1970-01-01
  • 1970-01-01
  • 2019-05-11
  • 1970-01-01
  • 2020-02-26
  • 1970-01-01
  • 2019-09-12
  • 2012-01-23
相关资源
最近更新 更多