Search code examples
extjsstore

How to pass parameters to store in ExtJs


I am working on a display where I need to bind a combobox but I am unable to pass parameters. Below is my code please provide me the way to pass parameters.

//store
Ext.define('NetworkStore', {
    extend: 'Ext.data.Store',
    alias: 'NetworkStore',
    fields: ['Id', 'value'],
    storeId: 'NetworkStore', 
    autoLoad: true,
    proxy: {
        type: 'ajax',
        useDefaultXhrHeader: false,
        actionMethods: { create: "POST", read: "GET", update: "POST", destroy: "POST" },
        headers: { 'Content-Type': 'application/x-www-form-urlencode' },
        limitParam: false,
        startParam: false,
        pageParam: false,
        extraParams: {
            Style: 1
        },
        url: 'url',
        reader: {
            type: 'json'
        }
    }
});

xtype: 'combo',
name: 'NetworkIDList',
store: {
        type: 'NetworkStore',
        'Style': 3 //parameter
        //params: {  // tried this way as well but did not work for me.
        //  Style: 3
        //}
        }

Note: Store is defined in a separate file.


Solution

  • The store should be passed like below format.

    store: {
            type: 'NetworkStore',
            proxy: {
                    extraParams: {
                        Style: 3
                    }
                }
            }