Extjs paging toolbar problem
When I try to show five rows only, the paging toolbar says "showing 1-5 of [however many items I got in db]", the problem is that the grid actually shows the entire db even if it says it shows just the 5 items. This is my store:
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,
});
the model:
Ext.regModel('orderModel', {
fields : [ {
name : 'order_number',
type : 'string'
}, {
name : 'status',
type : 'string'
}, {
name : 'time_of_delivery',
type : 'string'
}, {
name : 'last_edited',
type : 'string'
} ]
});
before I create my grid, I load the store:
viewOrder.load({
params : {
start : 0,
limit : 5,
}
});
my grid:
xty开发者_开发技巧pe : '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',
} ]
Can you see if I'm doing something wrong? I tried following the sencha documentation, but obviously that did not work properly.
When a request gets sent to the server for 5 items, do you only return the 5 items it requests? It's up to you to do the appropriate filtering on the server.
See the totalProperty option here: http://docs.sencha.com/ext-js/4-0/#/api/Ext.data.reader.Json
The totalProperty refers to the property in your response that contains the total number of records. It defaults to total, so your response should look something like:
{
"total": 20,
"records": [{
"a": "foo"
}]
}
In doing so you will also need to set the root property on the reader appropriately, in the example above it would be "records".
精彩评论