ترحيل شبكة extJS: الزر التالي معطل!
سؤال
لقد قمت بإنشاء شبكة أساسية تحتوي على شريط أدوات ترحيل. لسبب ما عندما أقوم بتحميله في الفهرس 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"
})
});
}
استجابة JSON:
{"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 في متجر JSON الخاص بك:
var myStore = new Ext.data.Store({
reader: new Ext.data.JsonReader({
totalProperty: 'total_count',
...
}),
...
});
لا تنتمي إلى StackOverflow