开发者

extjs dynamic store?

I'm trying to build an app using tha MVC model and although most things are going well i'm having issues with the new architecture. The problem at hand is that i have created a store using this

Ext.define('MCMS.store.Items', {
extend: 'Ext.data.Store',
model: 'MCMS.model.Item',
autoLoad: {'limit':10},
pageSize:10,
remoteSort:true,
proxy: {
    url:'/ajax/moduleLoaded.php',  
    actionMethods: 'post',
    extraParams :{'code': code,'toLoad':'latestContet','return':'json','module':Ext.getDom('module').value,'test':function(){console.log(this)}},
    type: 'ajax',
    reader: {
        type: 'json',
        successProperty: 'success',
        root: 'items'

    }
}

});

This works fine, but i need the module param to be dynamic depending on the view that is using it. Let's say that i have 1 grid like this

Ext.define('MCMS.view.items.List' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.itemsList',
title : lang.items,
store: 'Items',
loadMask: true,
columns: [
        {header: "#ID", width: 60, dataIndex: 'id', sortable: true,filter: {type: 'numeric'}},
        {header: "Title", width: 250, dataIndex: 'title', id:'title', sortable: true,filter: {type: 'string'}},
        {header: "Availability", width: 60, dataIndex: 'active', sortable: true,renderer: function(value, metaData, record, rowIndex, colIndex, store) { if (value == 1) { return '<span style="color:green;">' +lang.yes + '</span>'; } else { return '<span style="color:red;">' + lang.no + '</span>'; } }},
        {header: "Category", width: 200, dataI开发者_如何学Gondex: 'category',sortable:false,renderer: function(value, metaData, record, rowIndex, colIndex, store) {                          
            var cat = new Array;
            Ext.each(value, function(person, index) {
                cat.push('<a href="#showCat" class="catDetails" rel="'+ this.categoryid + '">' + this.category + '</a>');
            });
            return cat.join(' , '); }},
],
selModel: Ext.create('Ext.selection.CheckboxModel'),
columnLines: true,
dockedItems: [ {
        xtype: 'toolbar',
        items: [{
            text:'Add Something',
            tooltip:'Add a new row',
            iconCls:'add',
            itemId:'addItem'
        }, '-', {
            text:'Options',
            tooltip:'Set options',
            iconCls:'option'
        },'-',{
            itemId: 'removeButton',
            text:'Remove Something',
            tooltip:'Remove the selected item',
            iconCls:'remove',
            disabled: true
        }]
    }],
    bbar: {xtype: 'itemsPaging' },
    features: [filters],

}); and i use this grid in 3 or 4 different occasions but the data needs to change depending on the view that it's using it. All i need is a way to change the module parameter somehow.


Try using this code:

store.getProxy().extraParams.module = newValue;
store.reload();


If I understand you correctly, you need to use grid.reconfigure() to change the makeup of a grid and allow alterations to its store.


You could set the extraParams directly

store.getProxy().extraParams.module = newValue;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜