Sencha Touch列表中的默认项目选择

时间:2014-07-20 08:50:26

标签: sencha-touch sencha-touch-2.3

默认情况下如何选择列表中的第一项,而不点击它?以下是我的观点。

Ext.define('MyApp.view.TestList', {
    extend: 'Ext.List',
    xtype: 'testlist',
    config: {
        flex: 1,
        enableSelection: true,
        itemTpl: '{item}',
        data: [
            {item: 'item-1'},
            {item: 'item-2'},
            {item: 'item-3'},
            {item: 'item-4'}
        ]
    }
});

1 个答案:

答案 0 :(得分:1)

Ext.List有两种方法可以帮助你:

list.select( record, keepExisting, surpessEvent );
list.selectRange( startRecordIndex, endRecordIndex, keepExisting );

在您的情况下,您可以使用list.selectRange( 1, 1, false );选择第二条数据记录。