ExtJS4 - 网格存储页面大小

标签 extjs4

我试图将商店的 pageSize 限制为 1。我在网格中有 10 个项目,虽然分页机制正确显示 10 个中的 1 个、10 个中的 2 个等,但网格仍显示所有 10 个项目。我也试过在 json 中将“total”属性返回到 1 但这仍然不起作用。有任何想法吗?

文档中的示例也不是很有帮助,因为它显示了源代码,但实时预览是空的。

        var photos = new Ext.data.Store({
            model: 'Photos',
            autoLoad: true,
            pageSize: 1
        });

        var photosGrid = Ext.create('Ext.grid.Panel', {
            id: 'PhotoGrid',
            store: photos,
            columns: [
                       { text: "Filename", width: 200, dataIndex: 'filename' }
                    ],
            dockedItems: [{
                xtype: 'pagingtoolbar',
                store: photos,
                dock: 'bottom',
                displayInfo: true
            }],
            region: 'center',
            border: 0,
            overCls: 'row-pointer'
        });

最佳答案

嘿,你的问题是你可能在你的 json 中返回了所有 10 个项目,你必须自己实现分页支持,所有分页所做的就是使用特定的参数调用商店的负载,比如页面的限制和页面开始索引。您必须在后端使用这些参数一次发送一项。切尔的伙伴。

编辑

//this is the model we will be using in the store
Ext.define('Page', {
    extend: 'Ext.data.Model',
    fields: [
        {name: 'id',    type: 'int'},
    ]
});

var data = null;
var store = null;
Ext.Ajax.request({
    url: 'someurl',
    success: function(result){
        data = Ext.decode(result.responseText);
        store = Ext.create('Ext.data.Store', {
            autoLoad: true,
            model: 'Page',
            pageSize: 1,
            data : data,
            proxy: {
                type: 'memory',
                reader: {
                  type: 'json',
                  root: 'pages'//this has to be as the root from your json
                }
            }
        }); 
    }
});

关于ExtJS4 - 网格存储页面大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8205563/

相关文章:

callback - EXTJS 4.0 : how to implement callback method for store. 同步()方法?

javascript - ExtJS 6.2 与 4.x 中的 Ext.state.Manager.setProvider() 行为

javascript - 我可以使用 sencha extjs 商店和模型进行 sencha touch 吗?

ExtJs 和嵌套模型

javascript - 如何将 css 类添加到 Ext4 中的树节点?

javascript - EXTJS:隐藏元素在 setvisible 后不显示

json - 无法使用 JSON 结果将数据呈现到网格列中

ajax - EXTJS 4 : Selective Ajax Request Aborting

javascript - extjs4 如何重置我修改过的商店