1. #1
    Ext User
    Join Date
    Sep 2007
    Location
    Vancouver, BC
    Posts
    33
    Vote Rating
    0
    juandj is on a distinguished road

      0  

    Default 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!

  2. #2
    Ext User Grimsk's Avatar
    Join Date
    Jul 2007
    Location
    Saint-Georges, Canada
    Posts
    101
    Vote Rating
    0
    Grimsk is on a distinguished road

      0  

    Default


    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

    Code:
    var jsondata = Ext.util.JSON.encode( yourArray );
    then
    Code:
    		this.conn.request({
    			method: 'POST', 
    			callback: function(){ 
    				alert( 'whaaa im done' );
    			},
    			url: http://anyUrl.com, 
    			params: {
    				anyThing: 'wra'
    				paramsWithArrayJson: jsondata 
    			}
    		});

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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.

  4. #4
    Ext User
    Join Date
    Sep 2007
    Location
    Vancouver, BC
    Posts
    33
    Vote Rating
    0
    juandj is on a distinguished road

      0  

    Default


    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!!

  5. #5
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,508
    Vote Rating
    56
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    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"]
            }
        });

Thread Participants: 2