PDA

View Full Version : Grid not paging



Angilo
28 Apr 2010, 12:28 PM
Hi,

I'm pretty new to Ext JS, but so far I'm having a great experience using it.

I think there is something wrong with my store.



SalesDataStore = new Ext.data.Store({
id: 'SalesDataStore',
proxy: new Ext.data.HttpProxy({
url: '/controllers/sales.php',
method: 'POST'
}),
baseParams:{action: "list", sd: "{/literal}{$sd}{literal}" },
reader: new Ext.data.JsonReader({
// we tell the datastore where to get his data from
root: 'results',
totalProperty: 'total',
id: 'id'
},[
{name: 'orders_id', type: 'int', mapping: 'orders_id'},
{name: 'order_total', type: 'float', mapping: 'order_total'},
{name: 'customers_company', type: 'string', mapping: 'customers_company'}
]),
sortInfo:{field: 'orders_id', direction: "DESC"}
});


This is the code for my grid



SalesListingEditorGrid = new Ext.grid.GridPanel({
id: 'SalesListingEditorGrid',
store: SalesDataStore, // the datastore is defined here
cm: SalesColumnModel, // the columnmodel is defined here
enableColLock:false,
title: 'Sales orders',
selModel: new Ext.grid.RowSelectionModel(
{
listeners: {
rowselect: function(sm, row, rec) {
addTab('Order #' + rec.data.orders_id, '/controllers/sales.php?sd={/literal}{$sd}{literal}&action=edit&oID=' + rec.data.orders_id);
}
}
,
singleSelect:true}
),
// paging bar on the bottom
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: SalesDataStore,
displayInfo: true,
emptyMsg: "No sales to display"
})
});


And the loading of data



SalesDataStore.load({params:{start:0, limit:10}}); // Load the data


The file sales.php returns 283 rows which are being displayed all at once.

What am I doing wrong?

Thanks in advance,

Best Regards.


[EDIT]

And oh, of course the store which is calling /controllers/sales.php posts vars named "start" + "end". I can use it in my query of course, then the paging will work good. But then sorting by the grid is not possible...

cnelissen
28 Apr 2010, 12:37 PM
Yes, paging causes unexpected sorting behavior, or rather sorts the paged data rather than the whole dataset. You just need set remoteSort: true on your store. Then include the sort field in your query as well.