Results 1 to 4 of 4

Thread: Changing extraparams for a treestore at runtime

  1. #1
    Sencha User
    Join Date
    Jan 2013
    Posts
    6
    Vote Rating
    0
      0  

    Default Unanswered: Changing extraparams for a treestore at runtime

    I am trying to change extraparams of a treestore at runtime. I have tried the following (works on a normal store not treestore):
    Code:
     myshoporders_tree_store.getProxy().setExtraParam('order_no', order_no);  myshoporders_tree_store.reload();
    Since i could not get the above to do what i wanted, i found a solution like this:
    Code:
     myshoporders_tree_store.reload({     params:{ order_no:order_no }   });
    The only problem with the solution is that the params are not persistent i.e. after the filter, the params get reset again on store reload, tho i wud like to maintain the params for other purposes. Or am I not doing it right? Pls help. Thnx.
    My treestore:
    Code:
     var myshoporders_tree_store = Ext.create('Ext.data.TreeStore', {     autoload: false,     model: 'myshop_order_model',     proxy: {         type: 'ajax',         url: 'includes/order_cats.php',         extraParams: {shop_id: '',cat: '',status: '',order_date: '',order_no: '',buyer_name: '',order_id: '',id: ''},         reader: {             root: 'orders',             totalProperty  : 'totalCount'         }     },     folderSort: false  });
    My model:

    Code:
     Ext.define('myshop_order_model', {     extend: 'Ext.data.Model',     idProperty: 'id',     fields: [         { name: 'id', type: 'string' },         { name: 'cat', type: 'string' },         { name: 'shop_id', type: 'string' },         { name: 'plid', type: 'string' },         { name: 'invid', type: 'string' },         { name: 'rectype', type: 'string' },         { name: 'order_number', type: 'string' },         { name: 'order_date', type: 'string' },         { name: 'buyer_name', type: 'string' },         { name: 'status', type: 'string' },         { name: 'read', type: 'string' },         { name: 'invoice_total', type: 'string' },         { name: 'total', type: 'string' }      ] });

  2. #2
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,154
    Answers
    501
    Vote Rating
    249
      0  

    Default

    The below test case worked for me:
    *Click Load > Set Params > Reload

    Code:
    var store = Ext.create('Ext.data.TreeStore', {
        fields: ['foo'],
        proxy: {
            type: 'ajax',
            url: 'data/json.json',
            extraParams: {
                one: 'one'
            }
        }
    });
    
    
    Ext.widget('button', {
        renderTo: document.body,
        text: 'Load Store',
        handler: function () {
            store.load();
        }
    });
    
    
    Ext.widget('button', {
        renderTo: document.body,
        text: 'Set Params',
        handler: function () {
            store.getProxy().setExtraParam('one', 'two');
        }
    });
    
    
    Ext.widget('button', {
        renderTo: document.body,
        text: 'Reload Store',
        handler: function () {
            store.reload();
        }
    });
    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our human resources manager: fabienne.bell@sencha.com

  3. #3
    Sencha User
    Join Date
    Jan 2013
    Posts
    6
    Vote Rating
    0
      0  

    Default

    Hi Slemmon,
    Apparently the extraparam never changes in my case as per your example, based on firebug output. The extraparam 'one' always has the value 'one'. No matter how many times i click on set params-> reload. Is it changing to 'two' in your case?
    I have to click load once again for the new values to be visible i.e.
    Load->set params->reload->Load
    Is this how it should behave really? The Reload alone should be able to show the new param values. I dont have to reclick load to see the new values.
    I cannot replicate this same behaviour in my app since the app does all these actions (Load->set params->reload->load) in the background without user intervention.

  4. #4
    Sencha - Support Team slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,154
    Answers
    501
    Vote Rating
    249
      0  

    Default

    It worked for me. I loaded the store the first time and reviewed the transaction in the Network tab of the browser dev tools and I see:
    _dc=1374088332976&one=one&node=root

    I click on the Set Params Button and then the Reload button and see:
    _dc=1374088335509&one=two&node=root
    which reflects the changed valued for the one param.

    I then click on Load once more just to see that the change takes effect with load() and reload() and I see:
    _dc=1374088352350&one=two&node=root
    Are you a Sencha products veteran who has wondered what it might be like to work at Sencha? If so, please reach out to our human resources manager: fabienne.bell@sencha.com

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
  •