2012-11-05 63 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分组,但没有排序。 –