簡體   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