View Full Version : How to inject parameters to a EXT sort or page event

15 Aug 2010, 5:24 PM
Hello to all,

Sorry for the double post for some reason I thought my first atemp was diregarded.

Hello to all,

I am not sure if this is a an EXT designer issue but since I am using the tool to build the UI I will start here.

I am using EXT Designer for a rather complex UI an so far everything is working okay. This is what I have so far:
1) added a JSON store and wired it to the GridPanel.
2) The store is not set to autoload since the data query needs to have search values associated prior to the execution.
3) Once the user executes the query based on the values selected I issue an ajax call and pass 6 params that will be used to narrow down my query results on the server (servlet/action) by dynamically building a where clause
4) I populate the grid from the results of the server action. See my simple code snippet.

url: 'executeQuery.do',
method: 'post',
params: {
values0: queryParam['values0'],
values1: queryParam['values1'],
values2: queryParam['values2'],
values3: queryParam['values3'],
values4: queryParam['values4'],
values5: queryParam['values5']
success: function(responseObject) {
jsonData = Ext.util.JSON.decode(responseObject.responseText);
var dataStore = Ext.StoreMgr.get('MyStore');
failure: function() {

All of this appears to be working properly when I displaying the first page but now I need to include “paging” and “Remote Sorting” which I thought I could do easily.
I associated a URL (i.e. executeQuery.do) to the JSONStore but my problem is that any time the user pages or performs a sort I also need to pass the original query prams (which I keep available in my Javascript) in order for the servlet to generate the dynamic SQL.


The actual values are something like (i.e. values0 "1,2,3,4,5,6" or values1 "ga, al, ca, fl" etc.) the servlet converts them into a series of where clauses using the IN SQL statement and feeds them to my SQL statement.

It is not oblivious to me how I can intercept the sort and paging ext events just before they are sent back to the server so that I can “inject” additional parameters that will be available to my servlet/action.
One thought that occurred to me is that I could probably do a quick fix by creating session variables and track state, then any time a sort or paging action is requested I can just access my session variables that provide my where clause. But I was hoping to avoid this, unless this is the best practice for EXT development.

Could anyone point me in the right direction as to how I can leverage EXT to do this? Or better yet if anyone has had the same dilemma how it was resolved

Thanks in advance,


17 Aug 2010, 12:28 PM
you don't need to manually load the store. you can set store's baseParams property as you set in ajax params, then just call load method of store.

when you've set the baseParams, each store load action will pass those params to internal ajax call which will do what you want.

17 Aug 2010, 6:14 PM
Thanks you j-joey this really simplifies the block of code.

For those of you who might be interested in knowing how it would look like this is how I did it based on j-joey suggestion, Paging or sorting is also working with no extra code

var dataStore = Ext.StoreMgr.get('MyStore');
dataStore.baseParams = {
values0: queryParam['values0'],
values1: queryParam['values1'],
values2: queryParam['values2'],
values3: queryParam['values3'],
values4: queryParam['values4'],
values4: queryParam['values5'],