extjsグリッドページング:次のボタンが無効になっています!
質問
ページングツールバーを備えた基本的なグリッドを作成しました。インデックス0でロードされると、テキストが「5/5ページを表示する」と書かれていても、次のページボタンは無効になります。ストアのロードパラメーションで0より高いものを選択すると、前後にページを付けることができますが、ページの最大#を適切に表示せず、最初のページに戻ると、次のボタンは1回です。再び無効になっています。
何か案は?
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"
})
});
}
JSON応答:
{"data":[{ bug 1 },{ bug 2 },{ bug 3 },{ bug 4 },{ bug 5 }],
"errors":{},
"total_count":25}
解決
あなたはjsonreaderのtotalpropertyを読んでいません...
この構成をオートロードに追加する必要があります...
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ストアでJSONリーダーを定義することもできます。
var myStore = new Ext.data.Store({
reader: new Ext.data.JsonReader({
totalProperty: 'total_count',
...
}),
...
});
所属していません StackOverflow