-
21 Jan 2008 2:32 AM #1
Submit params as array?
Submit params as array?
Hi,
I'm updating a store via ajax, using baseParams. Is it possible to submit the params in array format?
An example: I have a multiple select with users, I want to use as a filter.
In my PHP script I would like to access the filter like this: $_POST['filter']['users'].
Thx for your help!
-
21 Jan 2008 9:18 AM #2
json encode it into a param on the client (assuming it is already an array or object):
then decode it on the server:PHP Code:store.load({params: {filter: Ext.encode(myArray)}});
PHP Code:$filter = json_decode($_POST['filter']);
$users = $filter['users'];
-
25 Jan 2008 7:42 AM #3
Ok, I need your help.
I would call store.load() with the same params as filter plugin does.
In a grid, when I filtered out a column, the store.load() is called with these params (thanks to firebug):
How can I pass an array (like filter) to the params object in a store.load() call?Code:filter[0][data][comparison] = eq filter[0][data][type] = numeric filter[0][data][value] = 555 filter[0][field] = theField
Using
doesn't do the job!Code:store.load({params: {filter: Ext.encode(myArray)}});
Firebug says that filter is an empty array... but I made it!
So, please, can you provide a simple, but complete, example?
Thanks
PS: this is my code. Please note that I've tried everything possible but without success.
PHP Code:var filterObj = new Array();
filterObj[0] = new Array();
filterObj[0]['data'] = new Array();
filterObj[0]['data']['type'] = 'numeric';
filterObj[0]['data']['value'] = value;
filterObj[0]['data']['comparison'] = 'eq';
filterObj[0]['field'] = childField;
var filterObj2 = filterObj;
var temp = new Array();
temp[0] = new Array();
temp[0]['field'] = 'IDPersona';
var temp2 = {a:'aaa', b:'bbb'};
var temp2b = temp2;
var temp3 = {a:'aaa', b:'bbb'};
var temp4 = new Array("uno", new Array("due", "tre"));
childTableToBeFiltered.grid.getStore().load({params:{
start:0,
limit:7,
temp:Ext.encode(temp),
temp2:Ext.encode(buildQuery(temp2)),
temp3:Ext.encode(temp3),
temp2b:buildQuery(temp2b),
filterObj: filterObj,
filterObj2:Ext.encode(filterObj2),
_temp:temp,
_temp2:temp2,
_temp3:temp3,
_temp4:temp4,
_temp4:Ext.encode(temp4)
}});
-
29 Jan 2008 1:43 AM #4
Solved!
Solved!
I solved by myself!
It was a simple misunderstanding of the syntax of params object.
You should use (note the quotes):
instead ofPHP Code:{
params:{
start:0,
limit:5,
'rowFilter[0][data][type]': 'numeric',
'rowFilter[0][data][value]': value,
'rowFilter[0][data][comparison]': 'eq',
'rowFilter[0][field]': theField
}
}
Hope that helps.Code:{params: {filter: Ext.encode(myArray)}}
-
7 Feb 2008 10:55 AM #5
I need to see this more as *regular* parms like ...
?dir="ASC"&comparison="GT"&type="numeric" ...
My program on the serverside is picking up dir, start, limit and sort ... but nothing in the array. Not sure how to handle this.Code:dir ASC filter[0][data][comparison] gt filter[0][data][type] numeric filter[0][data][value] 6 filter[0][field] msrp limit 20 sort company start 0
-
7 Feb 2008 11:29 AM #6
See the following example:
Will generate an URL like: ?dir=asc&comparison=gt&type=numericPHP Code:params: {
dir: 'asc',
comparison: 'gt',
type: 'numeric'
}
In your case, you have to do this:
So simple.PHP Code:params: {
dir: 'asc',
comparison: 'gt',
type: 'numeric',
value: 6,
field: 'msrp',
limit: 20,
sort: 'company',
start: 0
}
-
7 Feb 2008 11:42 AM #7
Never mind. Solved.
Thank you.


Reply With Quote

