Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
EXTJS4-在网格中分页不正确_Extjs_Extjs4 - Fatal编程技术网

EXTJS4-在网格中分页不正确

EXTJS4-在网格中分页不正确,extjs,extjs4,Extjs,Extjs4,我在store中设置了pagesize,在proxy设置中设置了totalproperty,还定义了dockedItems配置。但在页面中,将显示所有记录,而不是指定的页面大小。这是我的密码: js文件: var sm = Ext.create('Ext.selection.CheckboxModel'); Ext.define('SuperUser', { extend: 'Ext.data.Model', fields: [

我在store中设置了pagesize,在proxy设置中设置了totalproperty,还定义了dockedItems配置。但在页面中,将显示所有记录,而不是指定的页面大小。这是我的密码:

js文件:

var sm = Ext.create('Ext.selection.CheckboxModel'); 
    Ext.define('SuperUser', {
        extend: 'Ext.data.Model',
        fields: [
            { name: 'fname', type: 'string' },
            { name: 'lname', type: 'string' },
            { name: 'email', type: 'string' },
            { name: 'uid', type: 'string' },
            { name: 'isSup', type: 'boolean' },
            { name: 'upDate', type: 'string' },
            { name: 'upBy', type: 'string' }
        ]
    });
  //Create the grid
    var superGrid=Ext.define('supusergrid', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.supusergrid',
    title: 'Super Admin Grid',
    gridId:'grid',
    model:'SuperUser',
    store: Ext.create('Ext.data.Store', {
        storeId: 'supUserStore',
         pageSize: 3,
        model:'SuperUser',
        autoLoad: true,
            proxy: { 
                type: 'ajax',
                url : 'supUserStore.json',
                reader: {
                    type: 'json',
                    root: 'data',
                    totalProperty:'total' 
                    } 
                }
    }),
    selModel: sm,
    columns: [
              { 
                  header: 'First Name',
                  dataIndex: 'fname' 
            },
              {
                header: 'Last Name', 
                dataIndex: 'lname' 
                },
              { 
                    header: 'Email', 
                    dataIndex: 'email'
                    },
              { 
                        header: 'User ID', 
                        dataIndex: 'uid' 
                        },

             {
                 header: 'Super Admin', 
                 dataIndex: 'isSup'
                 },
              { 
                     header: 'Updated Date',
                     dataIndex: 'upDate',

                     },
              { 
                         header: 'Updated By',
                         dataIndex: 'upBy'
                         }
          ],
          dockedItems: [{
              xtype: 'pagingtoolbar',
              store: Ext.data.StoreManager.lookup('supUserStore'),   
              dock: 'bottom',
              displayInfo: true
          }],
    initComponent: function () {
        this.callParent(arguments);

    }
});
    Ext.onReady(function () {
        Ext.widget('supusergrid', {

            renderTo: 'div1'
        });
    });
json文件:

{
    "success": true,
    "total": 12,
    "data":  [
                { "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jane","lname":"Smith","email": "j.smith@netapp.com", "uid": "jsmith","isSup":false,"upDate":"11-19-2012","upBy":"aaron@netapp.com" },
                { "fname": "Jim","lname":"Smith","email": "jm.smith@netapp.com", "uid": "jmsmith","isSup":true,"upDate":"11-23-2012","upBy":"aaron@netapp.com"}
            ] 
}

请指出我的错误所在。

您使用的是一个。在您的服务器上,您可以拦截请求参数页、开始和限制。然后用页面数据创建一个json响应。

存储分页并不像您想象的那样聪明。仅仅因为你告诉它页面大小是3条记录,并且你总共有12条记录,并不意味着它会将所有内容分解成4个好页面

调用
store.loadPage
时,存储将
start
limit
参数添加到代理请求中。当响应返回时,它假定您已经正确地限制了结果集并加载了提供的所有记录。您有责任使用这些参数限制返回到存储区的结果。通常,这需要在服务器上发布数据,以便您可以利用这些参数

谢天谢地,有一个UX组件可以帮助您:


下面是一些示例代码,展示了它的工作原理:

尝试在网格之前创建存储。我猜查找失败了,因为它还没有创建。嗨,阿斯哥特,谢谢回复!好的,如果我在网格之前创建存储,如下所示,问题就不会解决。部分代码如下:var supUserStore=Ext.create('Ext.data.store',{storeId:'supUserStore',pageSize:3,model:'SuperUser',autoLoad:true,})//创建网格var superGrid=Ext.define('supusergrid',{extend:'Ext.grid.Panel',别名:'widget.supusergrid',标题:'Super Admin grid',grid:'grid',模型:'SuperUser',store:Ext.data.StoreManager.lookup('supUserStore'),selModel:sm,尝试在initComponent中添加:supUserStore.loadPage(1);你能为这段代码创建一个新的代码吗?下面是路径:除了上面使用的JSON文件之外。我在这里没有使用任何服务器端代码。硬编码JSON文件。