【问题标题】:Sencha touch dataview eventhandler for itemSencha touch dataview 项目的事件处理程序
【发布时间】:2013-04-08 12:06:13
【问题描述】:

平台:Sencha Touch 2.1

我试图通过点击数据视图中的项目来调用一个事件,但作为一个新手无法弄清楚。

 {
    xtype: 'dataview',
    cls: 'ownprofile-top',
    itemId: 'profileOptions',
    store: { fields: ["name", { name: "optionsButtons", type: 'string' }],
    data: [
        { name: 'First Option', event: 'onFirstBtnTap' },
        { name: 'Second Option', event: 'onSecondBtnTap'},
        { name: 'Third Option', event: 'onThirdBtnTap'}
    ]
    },
    scrollable: null,
    cls: 'profile-item',
    itemTpl: new Ext.XTemplate(
    '{name}'
    )
}

因此,点击任一选项,我希望触发一个事件或调用另一个方法来执行 xyz。

【问题讨论】:

    标签: extjs touch dataview


    【解决方案1】:

    你可以给itemtap添加一个监听器

    {
        xtype: 'dataview',
        cls: 'ownprofile-top',
        itemId: 'profileOptions',
        store: { fields: ["name", { name: "optionsButtons", type: 'string' }],
        data: [
            { name: 'First Option', event: 'onFirstBtnTap' },
            { name: 'Second Option', event: 'onSecondBtnTap'},
            { name: 'Third Option', event: 'onThirdBtnTap'}
        ],
        listeners: {
           itemtap: function(dataview, index, target, record, e, eOpts) {
               //Do xyz
           }
        }
    }
    

    【讨论】:

    • itemtap 是系统方法吗?除非它对 itemtap 有任何引用,否则我的数据视图将如何收听?
    • itemtap 是您的数据视图在点击项目时抛出的事件。它在文档中:Fires whenever an item is tapped 单击 here 获取文档。
    【解决方案2】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多