在ExtJs中,我们总是需要totalProperty来获得分页工作。但这需要后台检索所有数据才能计算“总计数”。
有没有办法让extjs的分页/无限滚动不需要总计数就能工作?所以我们只是继续滚动,直到它没有更多的记录,并在那里结束。
发布于 2021-01-13 07:28:22
totalCount属性可以在下一次AJAX请求期间更改(它不是常量值)。以下是经典工具包7.1版的示例:
Ext.application({
name: 'Fiddle',
launch: function () {
// Store Model
Ext.define('ForumThread', {
extend: 'Ext.data.Model',
fields: [
'title'
]
});
// Named Buffered Store
Ext.create('Ext.data.BufferedStore', {
storeId: 'threadsStore',
model: 'ForumThread',
leadingBufferZone: 2,
pageSize: 10,
proxy: {
type: 'ajax',
url: 'data1.json',
reader: {
rootProperty: 'topics',
totalProperty: 'totalCount'
},
},
autoLoad: true,
});
// Infinite Grid using the Buffered Store
Ext.create('Ext.grid.Panel', {
title: "Infinite Grid",
store: "threadsStore",
renderTo: Ext.getBody(),
width: "100%",
height: 400,
features: [{
ftype: 'grouping',
}],
plugins: [{
ptype: 'bufferedrenderer'
}],
columns: [{
dataIndex: 'title',
flex: 1
}]
});
}
});和动态数据:
var totalCount = params.start + 10*params.limit;
var topics = [];
for(i=params.start; i<params.start+params.limit; i++) {
topics.push({
title: 'title_' + i
})
}
return {
"totalCount": totalCount,
"topics": topics
};https://stackoverflow.com/questions/65681447
复制相似问题