繁体   English   中英

Extjs分页工具栏问题

[英]Extjs paging toolbar problem

当我尝试仅显示五行时,分页工具栏上显示“显示1-5,其中[我在数据库中获得了多少个项目]”,问题是网格实际上显示了整个数据库,即使它说只显示了5。项目。 这是我的商店:

var viewOrder = Ext.create('Ext.data.Store', {
    model : 'orderModel',
    pageSize: 5,
    proxy : new Ext.data.HttpProxy({
        type : 'ajax',
    url : 'allOrderJson',
    method : 'GET',
    reader : {
        type : 'json',
        root : 'jsonArray',
        totalProperty : 'total'
    }
}),
autoLoad: false,
});

该模型:

Ext.regModel('orderModel', {
    fields : [ {
        name : 'order_number',
        type : 'string'
    }, {
    name : 'status',
    type : 'string'
    }, {
    name : 'time_of_delivery',
    type : 'string'
    }, {
         name : 'last_edited',
         type : 'string'
    } ]
});

在创建网格之前,请加载商店:

viewOrder.load({
    params : {
        start : 0,
        limit : 5,
    }
});

我的网格:

xtype : 'grid',
    id : 'incompleteorders',
    title : 'outstanding orders',
    store : viewOrder,

    columns : [ {
        text : 'order number',
        dataIndex : 'order_number',
    }, {
        text : 'status',
        dataIndex : 'status',
    }, {
        text : 'delivery date',
        dataIndex : 'time_of_delivery',
    }, {
        text : 'last edited',
        dataIndex : 'last_edited',
    }, ],
    dockedItems : [ {
        xtype : 'pagingtoolbar',
        pageSize : 5,
        store : viewOrder, 
        dock : 'bottom', 
        displayInfo : true,
        emptyMsg : 'No data to display',
    } ]

你能看看我做错了什么吗? 我尝试遵循sencha文档,但显然无法正常工作。

当请求发送到服务器的5个项目时,您是否仅返回它请求的5个项目? 您需要在服务器上进行适当的过滤。

请在此处查看totalProperty选项: http ://docs.sencha.com/ext-js/4-0/#/api/Ext.data.reader.Json

totalProperty是指响应中包含记录总数的属性。 它默认为total,因此您的响应应类似于:

{
    "total": 20,
    "records": [{
        "a": "foo"
    }]
}

这样做时,您还需要在阅读器上适当设置root属性,在上面的示例中将是“ records”。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM