2013-05-18 35 views

回答

0

是的,您可以通過在點擊列表中的項目時添加一個itemtap偵聽器來以編程方式執行此操作。例如,您有五個項目,並且您希望禁用第二個項目以在選中時突出顯示。名單中的Index在這裏發揮作用。

下面是代碼:

Ext.define('MyApp.view.MyList', { 
     extend: 'Ext.dataview.List', 

     config: { 
      id: 'MyList', 
      store: 'MyArrayStore', 
      itemTpl: [ 
       '<div>{Value}</div>' 
      ], 
      listeners: [ 
       { 
        fn: 'onMyListItemTap', 
        event: 'itemtap' 
       } 
     ] 
    }, 

    onMyListItemTap: function(dataview, index, target, record, e, eOpts) { 
     if(index===1) // 1 is the 2nd item in the list 
     { 
      Ext.getCmp('MyList').getAt(index).setDisabled(true); //getting the list using id 'MyList', getting the item using index and then setting it as disabled. 
     } 

    } 

});