2012-11-05 65 views
3

我有我的名單是從php服務獲取數據,收到的數據是我需要的順序。但sencha會自動按字母順序排列我的列表。 下面是我的代碼:Sencha觸摸列表商店禁用排序

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

    config:  { 
     grouped: true, 
     plugins: [ 
      { 
       xclass:   'Ext.plugin.PullRefresh', 
       pullRefreshText: 'Pull down to refresh' 

      }, 
      { 
       xclass:  'Ext.plugin.ListPaging', 
       autoPaging: true, 
       noMoreRecordsText: 'No More Records' 

      } 
     ] 
    }, 
    initialize: function() { 
     this.callParent(arguments); 
     var store = Ext.create('Ext.data.Store', { 

      pageParam: 'page', 
      grouper: { 
       groupFn: function (record) { 
        return record.data.group_label; 
       } 
      }, 
      model: 'ListItem', 
      proxy: { 
       type: 'ajax', 
       url: '/m/services/activity_list_items.php', 
       reader: { 
        type:   'json', 
        rootProperty: 'root.results' 
       } 
      } 
     }); 

     var template = Ext.create('GenericListItem', { 
      hascounts: true, 
      hasicon: true, 
      varmap: { 
       descr: 'subtext', 
       count: 'sub_item_cnt', 
       itemid: 'itemid', 
       uniqid: 'uniqid' 
      } 
     }); 

     var emptyText = 'Recent Activity Items'; 
     this.setStore(store); 
     this.setItemTpl(template); 
     this.setEmptyText(emptyText); 
    } 
}); 

如何避免列表的自動排序?從列表的配置,如果你不想爲每個項目和強制頭刪除此

grouped: true 

回答

2

只需刪除該從你的店

grouper: { 
    groupFn: function (record) { 
     return record.data.group_label; 
    } 
} 

因爲基本上在您的情況grouper房產用於根據您的group_label字段按字母順序對您的項目進行分組。希望它有助於:)

+0

也許他仍然希望他們分組,但沒有排序? –

+0

是的,我想根據group_label分組,但沒有排序。 –