How can I change/add params on a store

后端 未结 4 654
萌比男神i
萌比男神i 2020-12-28 23:11

On a sencha-touch, here\'s is my store declaration

Ext.regStore(\'newsStore\',  {
    model: \'News\',
    autoLoad: true,
    proxy: {
        type: \'ajax\         


        
相关标签:
4条回答
  • 2020-12-28 23:52

    I suggest you a more elegant solution, the Sencha way to do that:

    //Take your store
    var store = Ext.StoreMgr.get('YOUR_STORE_ID');
    
    //Apply the params
    Ext.apply(store.getProxy().extraParams, {
        partyID: options.partyID,
        eventName: options.eventName
    });
    
    //Reload your store
    store.contactInfoId.read();
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-29 00:01

    You could try using extraParams:

    Ext.regStore('newsStore',  {
        model: 'News',
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: '../news/list.form',
            reader: {
                type: 'json',
                root: ''
            },
            extraParams: {
                format: 'json'
            }
        },                        
    });
    
    0 讨论(0)
  • 2020-12-29 00:13

    Store declaration

    new Ext.data.Store({
    model:'prj.models.ContactInfo',
    storeId:'contactInfoId',
    proxy:{
        type:'ajax',
        url:'/GetContactInfoByID',
        reader:{
            type:'json'
        },
        extraParams:{
            format:'json'
        },
        listeners:{
            exception:function(proxy, response, orientation){
                console.error('Failure Notification', response.responseText);
                Ext.Msg.alert('Loading failed', response.statusText);
            }
        }
    }   
    });
    

    Adding params to proxy and read ajax store

    prj.stores.contactInfoId.getProxy().extraParams.partyID = options.partyID;
    prj.stores.contactInfoId.getProxy().extraParams.eventName = options.eventName;
    prj.stores.contactInfoId.read();
    

    Hope this helps.

    0 讨论(0)
  • 2020-12-29 00:14

    For dynamically setting extra parameters:

    If you want to set single parameter at a time, you can use following

    var proxy= myStore.getProxy();
    proxy.setExtraParam('param1', 'value 1' );
    proxy.setExtraParam('param2' , 'value 2' );
    myStore.load();
    

    If you want to set multiple parameters at a time, you can use following

    proxy.setExtraParams({
         'param1':'value 1',
         'param2':'value 2'
    });
    
    0 讨论(0)
提交回复
热议问题