Sencha Touch - 取消选择列表项?

Ben*_*enM 12 javascript sencha-touch

我正在研究Sencha Touch应用程序,并有一个联系人列表.当点击列表项时,会显示一个ActionSheet,显示一些基本功能(如调用,删除和忽略).不幸的是,当用户点击并触发ActionSheet时,List项目仍然在叠加层下面被选中(参见下面的屏幕截图):

iOS模拟器的屏幕截图

这是绑定到itemTap事件的函数:

itemTap: function(list, index)
{
    // Deselect the selected record:
    var currentRecord = list.getStore().getAt(index);
    currentRecord.forename      = currentRecord.get('forename');
    currentRecord.surname       = currentRecord.get('surname');
    currentRecord.phoneNumber   = currentRecord.get('phoneNumber');
    currentRecord.shortFullName = currentRecord.forename + ' ' +  currentRecord.surname[0];

    list.getStore().deselect(index, true);

    callButton.setText('Call ' + currentRecord.shortFullName + ' (' + currentRecord.phoneNumber + ')');
    unfriendButton.setText('Remove ' + currentRecord.shortFullName + ' as friend');
    friendActionSheet.show();
}
Run Code Online (Sandbox Code Playgroud)

不幸的是,list.getStore().deselect(index, true)返回以下错误:Object [object Object] has no method 'deselect'

关于我可能做错了什么的想法,或者我如何能做到这一点?

Chr*_*ris 22

这对我有用:

    listeners: {
        itemtap: function(dv, ix, item, e) {
            // Clear the selection soon
            setTimeout(function(){dv.deselect(ix);},500);
        }
    }
Run Code Online (Sandbox Code Playgroud)


Sac*_*rke 11

在Sencha Touch 2中,在创建列表时使用disableSelection:true

Ext.define('App.view.NewsList',{
extend: 'Ext.List',
xtype: NEWS_LIST,

config: {
    store: NEWS_FEED,
    //deselectOnContainerClick: true,// not working in Sencha Touch 2
    disableSelection: true, // since Sencha Touch 2
    itemTpl: '{heading}'
} 
});
Run Code Online (Sandbox Code Playgroud)

  • 如果是**嵌套列表**,也可以使用该选项.但你必须将它添加到`listConfig`属性,如下所示:`listConfig:{disableSelection:true}` (3认同)