PDA

View Full Version : Refresh paging grid



mdombos
7 Sep 2007, 4:49 PM
Hi

I've created a paging grid with serverside filter. If no matches are found, the grid does not remove the records and the paging toolbar doesn't show the emptyMsg. How can I correct this, and what is the correct result format from server?

evant
7 Sep 2007, 5:43 PM
Shouldn't you already know if there's no items in advance? Post some code.

mdombos
8 Sep 2007, 3:52 AM
Shouldn't you already know if there's no items in advance? Post some code.
I don't understand the question! How would I know in advance, if a filter would result in empty?

CutterBl
8 Sep 2007, 6:08 AM
If your paging query, once filtered, returned an empty recordset, then your 'totalProperty' (JSON recordset) or 'totalRecords' (XML recordset) should come back with a value of 0. That being the case, the Paging Toolbar would no there are no records and display the emptyMsg you have set. This would also be dependent on if you are using remoteSort, whereby all of your filtering and such is being done server-side.

mdombos
8 Sep 2007, 8:06 AM
If your paging query, once filtered, returned an empty recordset, then your 'totalProperty' (JSON recordset) or 'totalRecords' (XML recordset) should come back with a value of 0. That being the case, the Paging Toolbar would no there are no records and display the emptyMsg you have set. This would also be dependent on if you are using remoteSort, whereby all of your filtering and such is being done server-side.

Yes, i know this. The server response is:


{"total":0,"results":null}

and here is the js code:


var ds = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: 'index.php?module=quing&func=getmydocs'
}),

reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id'
}, [
{name: 'doccode', mapping: 'doccode'},
{name: 'title', mapping: 'title'},
{name: 'country', mapping: 'country'},
{name: 'issue', mapping: 'issue'},
{name: 'savedon', mapping: 'savedon', type: 'date', dateFormat: 'Y-m-d h:i'},
{name: 'savedby', mapping: 'savedby'},
{name: 'locked', mapping: 'locked', type :'boolean'}
]),
remoteSort:true
});
this.grid = new Ext.grid.Grid('viewmydocs', {
ds: ds,
cm: this.cm,
selModel: new Ext.grid.RowSelectionModel({singleSelect:true}),
enableColLock:false,
loadMask: true,
autoExpandColumn: 'title'
});

var gridlayout = Ext.BorderLayout.create({
center: {
panels: [new Ext.GridPanel(this.grid)]
}
}, 'mydocs');
this.grid.render();
this.grid.on("rowcontextmenu", this.showMenu, this);

var gridFoot = this.grid.getView().getFooterPanel(true);
var paging = new Ext.PagingToolbar(gridFoot, ds, {
pageSize: 25,
displayInfo: true,
displayMsg: 'Displaying doccuments {0} - {1} of {2}',
emptyMsg: 'No documents to display'
});