Lista agrupada y ordenada en sencha touch 2

Tengo el siguiente código

Ext.regModel('Centre', {
   fields: ['name', 'url']
}); 

Ext.application({
    name: 'Sencha',

    launch: function() {

         var panel = new Ext.Panel({
        fullscreen: true,
        dockedItems: [
          {
            xtype: "toolbar",
            dock: "top",
            title: "DEMO APP"

          },
          {
            xtype: "toolbar",
            items: [
              {
                iconMask: true,
                iconCls: "download"
              },
              {
                iconMask: true,
                iconCls: "favorites"
              },
              {
                iconMask: true,
                iconCls: "search"
              },
              {
                iconMask: true,
                iconCls: "user"
              }
            ]  
          },
          {
            xtype: 'list',
            itemTpl: '{name}',
            sorters: 'name',

            store: {
                fields: ['name', 'url'],
                   data: centers
            },
            itemConfig: {
              tpl: '{url}'
            },
            listeners: {
              itemtap:function(data,index){
                var record = data.getStore().getAt(index);
                redirect_url = record.raw.url
                 // the record that has been clicked.
                 window.location = redirect_url
              }
            }
          },


        ]
      });   


   }
});

centers has a list of centers. I want to sort and group the list. Tried getGroupString() but didn't help. May be I am missing something..

preguntado el 08 de noviembre de 11 a las 19:11

2 Respuestas

Your list needs to have the config property grouped:true

(// indexBar:true as well if you want the alphabet on the side)

Your store needs to have the getGroupString function implemented

getGroupString: function(record) { return record.get('name') }

respondido 08 nov., 11:23

For anyone using 2.1+, the syntax is now to define a group object with a groupFn function in the config:

grouper: {
    groupFn: function(record) {
        return record.get('name').substr(0, 1);
    },
    sortProperty: 'name'
}

Respondido 29 Jul 13, 02:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.