PDA

View Full Version : Modifiying queries to retrieve data for paging grid



Dr.T
11 Dec 2007, 3:59 PM
I have a paging grid instance on a page and wish to allow users to enter parameters into a form on the same page which I wish to pass as parameters to the grid's data query to change the data being sent back and displayed in the grid

I have tried passing query parameters in to ExtJSInst.DataStore.doc_list.proxy.load (where doc_list is the id of the grid), which returns the required data, but the data stored in the proxy is not updated to reflect this data (and the grid is not updated).

How is one supposed to accomplish this?
(I can't see anything in the documentation or examples to help me with this)

Thanks for your help, regards,

Tim

FlexIDX
11 Dec 2007, 4:24 PM
I would like to know how to do this as well.


Chris

pigopl
11 Dec 2007, 9:08 PM
Tim,

First, call the load on the datastore not its proxy.

I guess you already tried this, as it is the more obvious thing to do, but, second, make sure you pass the url as a parameter.

If the you pass parameters, but not the url, the existing url will used, but the grid will not be updated (discovered this myself by mistake!).

e.g.

(assume start and limit are params for the paging and queryParam1 & 2 are the params you use to restrict the query at getgriddata)

ExtJSInst.DataStore.grid_id.load({url:'http://127.0.0.1/getgriddata',params: {'start': 0, 'limit': 25, queryParam1: "paramValue1", queryParam2: "paramValue2"}})

This should work.

sottwell
10 Jan 2008, 9:58 AM
This suggestion doesn't seem to work. I get the initial load with the third parameter passed just fine, but when using the paging toolbar it doesn't change anything, and Firebug shows the POST does not include the third parameter (limit and start are being passed), causing the query to fail and NULL to be returned.

ds.load({
url:'http://localhost/blah/grid-paging-data.php',
params:{start:0, limit:25, client:clientname}
});


I found another post that had this code:


ds.on('beforeload', function() {
ds.baseParams = {
client:clientname
};
});

and adding that just before the ds.load statement fixed my problem.

Stripeman
15 Jul 2009, 2:25 AM
old post I know.. but still applies.

This still works for passing a param from a 'filter' button from a tbar (not paging) to a paging function (next and prev)

IE:



{
xtype : 'buttongroup',
border : false,
columns : 3,
items : [{
text : ' Filters: ',
iconCls : 'filter'
},{
id : 'filter_inactive',
text : 'In-Active',
iconCls : 'details',
toggleGroup : 'filter',
enableToggle : true,
handler : function onItemClick(item, event) {

dataStore.on('beforeload', function() { // HERE
dataStore.baseParams = {
'orderby' : 'LastName',
'dir' : 'ASC',
'table' : 'Members',
'ac' : 'showData',
'page' : 'adminMembers',
'filter' : 'In-Active'
};
});
dataStore.load();

}

},{
id : 'filter_active',
text : 'Active',
iconCls : 'details',
enableToggle : true,
pressed : true,
toggleGroup : 'filter',
handler : function onItemClick(item, event) {

dataStore.on('beforeload', function() { // HERE
dataStore.baseParams = {
'orderby' : 'LastName',
'dir' : 'ASC',
'table' : 'Members',
'ac' : 'showData',
'page' : 'adminMembers',
'filter' : 'Active'
};
});
dataStore.load();
}

}]
}