1. #1
    Ext User
    Join Date
    Oct 2007
    Posts
    38
    Vote Rating
    0
    kgm is on a distinguished road

      0  

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

  2. #2
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    0
    devnull has a little shameless behaviour in the past

      0  

    Default


    json encode it into a param on the client (assuming it is already an array or object):
    PHP Code:
    store.load({params: {filterExt.encode(myArray)}}); 
    then decode it on the server:
    PHP Code:
    $filter json_decode($_POST['filter']);
    $users $filter['users']; 

  3. #3

    Default


    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):

    Code:
    filter[0][data][comparison] =    eq
    filter[0][data][type]        = numeric
    filter[0][data][value]        = 555
    filter[0][field]              = theField
    How can I pass an array (like filter) to the params object in a store.load() call?

    Using
    Code:
    store.load({params: {filter: Ext.encode(myArray)}});  
    doesn't do the job!

    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),
                                                          
    filterObjfilterObj,
                                                          
    filterObj2:Ext.encode(filterObj2),
                                                          
    _temp:temp,
                                                          
    _temp2:temp2,
                                                          
    _temp3:temp3,
                                                          
    _temp4:temp4,
                                                          
    _temp4:Ext.encode(temp4)
                                                       }}); 


  4. #4

    Default Solved!

    Solved!


    I solved by myself!

    It was a simple misunderstanding of the syntax of params object.

    You should use (note the quotes):

    PHP 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
       
    }

    instead of
    Code:
    {params: {filter: Ext.encode(myArray)}}
    Hope that helps.


  5. #5
    Sencha User
    Join Date
    Jan 2008
    Location
    Levittown, PA
    Posts
    316
    Vote Rating
    2
    mjhaston is on a distinguished road

      0  

    Default


    I need to see this more as *regular* parms like ...

    ?dir="ASC"&comparison="GT"&type="numeric" ...

    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
    My program on the serverside is picking up dir, start, limit and sort ... but nothing in the array. Not sure how to handle this.

  6. #6
    Ext User cadudecastroalves's Avatar
    Join Date
    Mar 2007
    Location
    Rio de Janeiro, Brazil
    Posts
    98
    Vote Rating
    0
    cadudecastroalves is on a distinguished road

      0  

    Default


    Quote Originally Posted by mjhaston View Post
    I need to see this more as *regular* parms like ...

    ?dir="ASC"&comparison="GT"&type="numeric" ...
    See the following example:
    PHP Code:
    params: {
        
    dir'asc',
        
    comparison'gt',
        
    type'numeric'

    Will generate an URL like: ?dir=asc&comparison=gt&type=numeric

    In your case, you have to do this:

    PHP Code:
    params: {
        
    dir'asc',
        
    comparison'gt',
        
    type'numeric',
        
    value6,
        
    field'msrp',
        
    limit20,
        
    sort'company',
        
    start0

    So simple.
    Cadu de Castro Alves
    Ext-user
    http://www.cadudecastroalves.com/

  7. #7
    Sencha User
    Join Date
    Jan 2008
    Location
    Levittown, PA
    Posts
    316
    Vote Rating
    2
    mjhaston is on a distinguished road

      0  

    Default


    Never mind. Solved.

    Thank you.