use extra params in store dynamically

前端 未结 5 2751
鱼传尺愫
鱼传尺愫 2021-02-20 17:59

I have a form. In the form, I am using a comboBox with a store.

{
    xtype: \'combobox\',
    id: \'SubContractor\',
    name: \'SubCo         


        
相关标签:
5条回答
  • 2021-02-20 18:20

    Sorry guys,

    I've spent more time to understand all available options and the different. Too many answers about this problem. I've summarized them and hope the answer will help someone.

    When you create a store (Supported in Ext JS 6.x.x, probably in earlier versions):

    var store = Ext.create('YourStore', {
        listeners: {
            // Fires before a request is made. op is an Ext.data.Operation object
            beforeload:function(store,op){
                // Set request parameters (without overriding other parameters)
                op.setParams(Ext.apply(op.getParams()||{},{
                    par1:'value'
                }));
            },
            ... 
    

    When you define a proxy of a store. Supported since Ext JS 4.x.x:

    proxy: {
        type: 'ajax',
        url: 'rest/dse',
        extraParams: {
            par1: 'value'
        }
    

    Note: The params are sent for multiple subsequent queries in this case!

    When you load data explicitly. Supported in all versions of Ext JS (since 3.x.x):

    store.load({
        params: { par1: "value" }
    });
    

    Note: it is not needed to put par1 inside of ‘’ or “”.

    Alternative sub-option, which uses access to proxy and its extraParams option:

    store.getProxy().extraParams = {
        par1: 'value'
    };
    store.load();
    

    Be careful with this. This parameter is sent for multiple subsequent queries!

    When you create a store. Supported only in Ext JS 3.x version.

    var genres1 = new Ext.data.Store({
        baseParams: {
            param1: 'value1',
            param2: 'value2'
        },
        // ...
    
    0 讨论(0)
  • 2021-02-20 18:31

    For extjs4, it's rather:

    store.load({
        params:{
            'foo1': bar1,
            'foo2': bar2
        } 
    });
    
    0 讨论(0)
  • 2021-02-20 18:34

    Try this:

      .
      . 
      proxy: {
        type: 'ajax',
        api: {
            create: CONTEXT_PATH + '/mvc/odon/create', 
            read: CONTEXT_PATH + '/mvc/odon/list',
            update: CONTEXT_PATH + '/mvc/odon/update',
            destroy: CONTEXT_PATH + '/mvc/odon/delete'
        },
        .
        .
    

    Passing the parameter:

     var storeDiagnostico= down('gridpanel').getStore();//Ext.create('store.odont.DStore');
            storeDiagnostico.getProxy().setExtraParam("idOdontologia", value);
            storeDiagnostico.load();
    
    0 讨论(0)
  • 2021-02-20 18:35
    store.getProxy().extraParams = {
        foo: 'bar'
    };
    store.load();
    
    0 讨论(0)
  • 2021-02-20 18:43

    In Chrome and FF even this will work:

    store.proxy.extraParams.foo= 'bar';
    

    But in IE8 (had this problem personally) got to do it the way mentioned by Evan

    store.proxy.extraParams = {foo: 'bar'};
    

    Check this...

    0 讨论(0)
提交回复
热议问题