Domanda

Ho creato una griglia di base che ha una barra degli strumenti di paging. Per qualche motivo quando carichi l'indice 0, il pulsante della pagina successiva è disabilitato, anche se il testo dice "Visualizzazione della pagina 1 di 5". Se scelgo qualcosa di più in alto di 0 nei parametri di caricamento per l'archivio, mi consente di pagina in avanti e indietro, ma non visualizza correttamente il numero massimo di pagine e se torno alla prima pagina, il pulsante successivo è una volta Ancora una volta disabilitato.

Qualche idea?

function getBugGrid(activityPanelWrapper){
  var pageSize = 5;
  var bugStore = new Ext.data.JsonStore({
                                          reader: new Ext.data.JsonReader({
                                                                            totalProperty: 'total_count'
                                                                          }),
                                          autoLoad: {params:{start: 0, limit: pageSize}},
                                          autoDestroy: true,
                                          url: '/bugs/fetch',
                                          idProperty: 'id',
                                          region: 'center',
                                          root: 'data',
                                          storeId: 'bugStore',
                                          fields: [...]
                                        });

  var columnModel = new Ext.grid.ColumnModel({
                                               defaults: {
                                                 width: 120,
                                                 sortable: true
                                               },
                                               columns: [...]
                                             });

  return new Ext.grid.GridPanel({
                                      region: 'center',
                                      store: bugStore,
                                      colModel: columnModel,
                                      trackMouseOver:false,
                                      loadMask: true,
                                      sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
                                      listeners: {
                                        rowclick: {
                                          fn: function(grid, rowIndex, event) {
                                            var bug_id = grid.store.getAt(rowIndex).id;
                                            Ext.getCmp('activity-panel').load(activity_lines_path(bug_id));
                                          }
                                        }
                                      },
                                      bbar: new Ext.PagingToolbar({
                                                                    pageSize: pageSize,
                                                                    store: bugStore,
                                                                    displayInfo: true,
                                                                    displayMsg: 'Displaying topics {0} - {1} of {2}',
                                                                    emptyMsg: "No topics to display"
                                                                  })
                                    });
}

Risposta di JSON:

{"data":[{ bug 1 },{ bug 2 },{ bug 3 },{ bug 4 },{ bug 5 }],
 "errors":{},
 "total_count":25}
È stato utile?

Soluzione

Non stai leggendo TotalProperty nel JsonReader ...

È necessario aggiungere questa configurazione al tuo caricamento automatico ...

var bugStore = new Ext.data.JsonStore({
  autoDestroy: true,
  url: '/bugs/fetch',
  idProperty: 'id',
  root: 'data',
  storeId: 'bugStore',
  fields: [ ... ]
  autoLoad: {params:{start: 0, limit: pagesize}}
});

Puoi anche definire un lettore JSON nel tuo negozio JSON:

var myStore = new Ext.data.Store({
reader: new Ext.data.JsonReader({
    totalProperty: 'total_count', 
    ...
}),
...

});

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top