Results 1 to 3 of 3

Thread: Some advise needed about setting ExtraParams in the store's proxy with Extjs 4.

  1. #1
    Ext JS Premium Member jvandemerwe's Avatar
    Join Date
    Apr 2009
    Location
    Raalte, Netherlands
    Posts
    202
    Answers
    6
    Vote Rating
    114
      0  

    Default Answered: Some advise needed about setting ExtraParams in the store's proxy with Extjs 4.

    Hello,

    Just looking for a bit of advise here. Is the following way of setting the value of the post parameters for a store "load" method, the way to go? Or are there better ways to do it. I don't like it so much to set parameters directly, without calling a function, given by the framework. It would be nice to have something like "store.setExtraParams".

    Code:
    // set an additional parameter before loading, not nice but effective
            store.getProxy().extraParams.someparameter1 = newValue1;
            store.getProxy().extraParams.someparameter2 = newValue2;
            store.load({
                scope   : this,
                callback: function(records, operation, success) {
                    this.ProcessSomethingUseful(records, operation, success);
                }
            });
    Thanks in advance.

    Johan

  2. Hello Tobiu,

    Yes you're right by setting the parameters at store definition time. But I have some parameters that change, before the store is reloaded. I used to work in Ext 3 with the undocumented store.setBaseParams.

    In my example the store is reloaded after the search field is changing and I want to refresh my results on the new value. So, yes I want this parameter constantly walking along.

    And yes your "params" on the load also works in Ext 4. Just tested it and this does the job too.

    Thank you for your quick reply.

    Johan

  3. #2
    Sencha User tobiu's Avatar
    Join Date
    May 2007
    Location
    Munich (Germany)
    Posts
    2,750
    Answers
    130
    Vote Rating
    128
      1  

    Default

    In Ext 3, you can set params in the load-call directly:

    Code:
    store.load({
        params : {...}
    })
    this should be possible in 4 too.

    you can also use the beforeLoad event to change params.

    the question is: do you want those params for ALL requests, then setting extraParams is fine. if it is just for this one call, i would go for the direct way.

    when adding more than one value to extraParams i would go for:

    Code:
    Ext.apply(store.getProxy().extraParams, {
        foo : 'bar',
        ...
    });
    Best regards
    Tobias Uhlig

  4. #3
    Ext JS Premium Member jvandemerwe's Avatar
    Join Date
    Apr 2009
    Location
    Raalte, Netherlands
    Posts
    202
    Answers
    6
    Vote Rating
    114
      0  

    Default Thank you

    Hello Tobiu,

    Yes you're right by setting the parameters at store definition time. But I have some parameters that change, before the store is reloaded. I used to work in Ext 3 with the undocumented store.setBaseParams.

    In my example the store is reloaded after the search field is changing and I want to refresh my results on the new value. So, yes I want this parameter constantly walking along.

    And yes your "params" on the load also works in Ext 4. Just tested it and this does the job too.

    Thank you for your quick reply.

    Johan

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •