Pregunta

Creé una cuadrícula básica que tiene una barra de herramientas de paginación. Por alguna razón, cuando me carga en el índice 0, el botón de página siguiente está deshabilitado, aunque el texto dice "Mostrar la página 1 de 5". Si elijo algo más alto que 0 en los parámetros de carga para la tienda, me permite hacer una página hacia adelante y hacia atrás, pero no muestra correctamente el # máximo de las páginas y si vuelvo a la primera página, el botón siguiente es una vez que es una vez que es nuevamente discapacitado.

¿Algunas ideas?

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"
                                                                  })
                                    });
}

Respuesta JSON:

{"data":[{ bug 1 },{ bug 2 },{ bug 3 },{ bug 4 },{ bug 5 }],
 "errors":{},
 "total_count":25}
¿Fue útil?

Solución

No estás leyendo la Propertía total en el JsonReader ...

Debe agregar esta configuración a su AutoC ...

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

También puede definir un lector JSON en su tienda JSON:

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

});

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top