Results 1 to 2 of 2

Thread: store.setBaseParam method look like some kind of weird

  1. #1
    Sencha User
    Join Date
    Oct 2010
    Posts
    2

    Default store.setBaseParam method look like some kind of weird

    Extjs version : 3.2.2
    store define code is :
    Code:
    var store = new Ext.data.JsonStore({
      root : 'list',
      autoLoad : {
       params : {
        start : 0,
        limit : 20
       }
      },
      totalProperty : 'totalRecord',
      idProperty : rowId,//your row id 
      remoteSort : true,
      fields : storeFields,//your store fields 
      url : 'equipments/grid-data.action' //your data proxy url
     });
    set baseParams later.
    Code:
    store.setBaseParam('test',1);
    store.reload();
    after store has reloaded.
    Code:
    alert(Ext.encode(store.lastOptions));//you will get '{"params":{"start":0,"limit":20,"test":1}}'
    and then.
    Code:
    store.setBaseParam('test',2);// change your base parameter
    store.reload();
    Code:
    alert(Ext.encode(store.lastOptions));//you will still get '{"params":{"start":0,"limit":20,"test":1}}','test' is still 1. it hasn't changed at all.
    but when store define code is :
    Code:
    var store = new Ext.data.JsonStore({
      root : 'list',
      autoLoad : {
       params : {
        start : 0,
        limit : 20
       }
      },
      totalProperty : 'totalRecord',
      idProperty : rowId,//your row id 
      remoteSort : true,
      fields : storeFields,//your store fields 
      url : 'equipments/grid-data.action' //your data proxy url
     });
    store.setDefaultSort(rowId,'desc');//just add this,sort by your row id ,you will see its effect
    Code:
    store.setBaseParam('test',1);
    store.reload();
    after store has reloaded.
    Code:
    alert(Ext.encode(store.lastOptions));//you will get '{"params":{"start":0,"limit":20}'
    and then.
    Code:
    store.setBaseParam('test',2);// change your base parameter
    store.reload();
    Code:
    alert(Ext.encode(store.lastOptions));//you will get '{"params":{"start":0,"limit":20}}' again.
    it seems setBaseParams doesn't just work as API description in previous situation.

  2. #2
    Sencha User hobophobik's Avatar
    Join Date
    Jul 2010
    Location
    UK
    Posts
    22

    Default

    Yup just had the same problem; it seems to be using the stores lastOptions params rather than the new base param you set. As a workaround, I've overwritten the value in lastOptions before doing my reload.

    Code:
    store.lastOptions.params.test = myNewValue;
    store.setBaseParam('test', myNewValue);
    store.reload();

Similar Threads

  1. [Extjs 3.2] PagingToolbar and setBaseParam
    By senacle in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 27 Sep 2011, 10:18 PM
  2. PagingToolbar Issue - page not rendering after setBaseParam is updated in store.
    By momospeedracer in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 15 Jul 2009, 11:15 AM

Posting Permissions

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