Вопрос

Я создал основную сетку, которая имеет панель инструментов пейджинга. По какой-то причине, когда я загружаю на индекс 0, кнопка «Следующая страница» отключена, даже если текст говорит «Отображение страницы 1 из 5». Если я выберу что-то выше, чем 0 в параметрах нагрузки для магазина, он позволяет мне продвинуться вперед и назад, но он не отображает максимальное количество страниц #, и если я вернусь на первую страницу, следующая кнопка один раз снова отключено.

Любые идеи?

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

Джосон ответ:

{"data":[{ bug 1 },{ bug 2 },{ bug 3 },{ bug 4 },{ bug 5 }],
 "errors":{},
 "total_count":25}
Это было полезно?

Решение

Вы не читаете TotalProperty в JsonReader ...

Вам нужно добавить этот конфиг на вашу автозагрузку ...

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

Вы также можете определить json Reader в вашем магазине JSON:

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

});

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top