-
22 Sep 2007 1:50 PM #1
adding array parameters via extraParams:
adding array parameters via extraParams:
I have been trying to figure out how to send array paramerers via extraParams
e.g.
http://url.com/?item[color]=red&item[size]=3&item[material]=plastic
I would expect this to be possible by:
extraParams: {mode:"additem", item: {color: "red", size: 2, material:"plastic"}}
but this doesnt work..
Is there a way to do this?
thanks!
-
22 Sep 2007 4:06 PM #2
you want to send your params with? data.Connection ? or for a grid? or..?
if you want to send them by Connection encode your array first
thenCode:var jsondata = Ext.util.JSON.encode( yourArray );
Code:this.conn.request({ method: 'POST', callback: function(){ alert( 'whaaa im done' ); }, url: http://anyUrl.com, params: { anyThing: 'wra' paramsWithArrayJson: jsondata } });
-
22 Sep 2007 10:44 PM #3
I don't think the OP wants to send JSON. The OP just wants to send parameters.
But didn't say from what kind of object, so we can't really help.
-
23 Sep 2007 1:29 AM #4
Thanks for the quick reply..
What im talking about is the parameter names for form fields. I am using a JsonReader with an httpproxy.
Lets consider a normal form
<form ... >
<input type="text" name="myitem[color]"></input>
<input type="text" name="myitem[name]"></input>
</form>
When this form is submitted (at least to PHP - Im not sure how other server-side langs will handle this) it will be put in an array automatically.
e.g. $_POST['myitem']['color'] and $_POST['myitem']['name'] would be how I access the values...
Now this works fine if I use the containername[itemname] notation in an extjs form for fields.. However, if I want to pass it from extraParams: for the httpproxy, I can't type the name with [ ] because it'll invalidate the whole script.. I dont know how to escape it either..
So I was wondering if this was possible at all..
Thanks!!
-
23 Sep 2007 7:51 AM #5
You can still have multiple fields with the same name in an Ext form, and it will submit an array.
But to submit extra params programatically with an Ext form, just add them to the submit options:
Code:myForm.submit({ params: { singleValueParam: "value", arrayParam: ["value1", "value2"] } });


Reply With Quote