2011-10-18 84 views
0

我已經使用示例代碼從「簡介列表組件」。我能夠在Android模擬器上成功運行它。現在我想通過firstName而不是lastName對它進行排序。當我更改爲sorters:「lastName」to firstName時,我可以看到索引欄不是按字母順序排列的。我怎樣才能按照正確的索引順序firstName排序?排序列表煎茶觸摸

Ext.regModel('Contact', { 
fields: ['firstName', 'lastName'] 
}); 

ListDemo.ListStore = new Ext.data.Store({ 
model: 'Contact', 
sorters: 'firstName', 

getGroupString : function(record) { 
    return record.get('lastName')[0]; 
}, 
data: [ 
    { firstName: "Domino",  lastName: "Derval" }, 
    { firstName: "Elektra",  lastName: "King" }, 
    { firstName: "Fiona",  lastName: "Volpe" }, 
    { firstName: "Holly",  lastName: "Goodhead" }, 


] 
}); 

回答

1

改變這一行:

  getGroupString : function(record) { 
       return record.get('lastName')[0]; 
      }, 

到:

  getGroupString : function(record) { 
        return record.get('firstName')[0]; 
     },