使用Ext js在网格中只显示有限的记录

Display only limited no of records in grid using Ext js

本文关键字:显示 记录 Ext js 网格 使用      更新时间:2023-09-26

我在使用Ext js制作网格时遇到了麻烦。所以我做了存储和网格。它工作得很好。但我的问题是,我有14000条记录,它显示在一个网格中,单镜头。但是我想只显示100条记录,然后像页面显示一样显示100条记录。我使用了分页工具栏,但我仍然没有得到它。请一些身体帮助我张贴你的代码。提前感谢。[对不起我的英语]

function some function(url)
  {
Ext.define('some model', {
            extend: 'Ext.data.Model',
            fields: some fields
      });
var store = Ext.create('Ext.data.Store',{
        id:'store',
        model:'some model',
        remoteGroup:true,
        remoteSort:true,
        proxy: {
            type:'rest',
            url:url
        reader: {
            type: "json",
            root:"myroot",
            idProperty:'id'
        }
        },
        autoLoad:true
}); 
return store;
}

var store= some function(url);
var grid = Ext.create('Ext.grid.Panel', {
                        id:'Grid',
                        title:'__________',
                        store: store,
                        loadMask: true,
                        width:'100%',
                        autoHeight:true,
                        viewConfig: {
                            emptyText:'No Available'
                        },
                        frame:false,
                        columns:[
                        {
                        id: 'c',
                        header:'bla',
                        dataIndex:'12',
                        width:'35%',
                        sortable:true,
                        },
                        {
                        id: 's',
                        header:'bla',
                        dataIndex:'21212',
                        width:'65%',
                        sortable:true,
                        }
                        ],
                     bbar: new Ext.PagingToolbar({
                            store:store,
                            pageSize:10,
                            id:'paging',
                            displayInfo:true,
                            displayMsg:'Displaying  {0} - {1} of {2}',
                            emptyMsg: "No Available",
                            prependButtons:false
                        }),
                       });

你的网格应该像这样

Ext.define('Com.grid.myGrid',{
            extend:'Ext.grid.Panel',
            alias:'widget.myGridAlias',
            store:'myStore',
                initComponent:function()
                {
                     this.bbar = Ext.create('Ext.PagingToolbar', {
                             store : this.store,
                             displayInfo : true,
                             displayMsg : 'Records {0} - {1} of {2}',
                             emptyMsg : 'No files.' 
                     });
                }
});

and and and你的Store应该像这样

Ext.define('Com.store.myStore',{
        extend:'Ext.data.Store',
        model : 'myModel',
        //autoLoad:true,
        pageSize: 100
});

这种类型的例子已经在Ext Js Sencha文档中提到过。这里是链接