We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 37286
    • 160 Posts
    I have a simple grid that displays extended fields for my addon, similar to the extended fields used in the user table. I would like to display the data in the grid without having to do another call to the processor. Is there a way to pass the json string to the grid?
    My grid:
    Addon.grid.ExtendedFields = function(config) {
        config = config || {};
        Ext.applyIf(config,{
            id: 'addon-grid-extendedfields'
            ,viewConfig: {
                forceFit: true,
                enableRowBody: true
            }
            ,fields: ['id','value']
            ,paging: false
            ,showPerPage: false
            ,remoteSort: true
            ,autoscroll: true
            ,columns: [{
                header: _('id')
                ,dataIndex: 'id'
                ,sortable: false
                ,width: 100
            },{
                header: _('value')
                ,dataIndex: 'value'
                ,sortable: false
                ,width: 100
            }]
        });
        Addon.grid.ExtendedFields.superclass.constructor.call(this,config);
    };
    Ext.extend(Addon.grid.ExtendedFields,MODx.grid.Grid);
    Ext.reg('addon-grid-extendedfields',Addon.grid.ExtendedFields);


    My code to get the data from the processor fills the form correctly, but the grid does not display the data:
    setup: function() {
            if (this.config.item_id === '' || this.config.item_id === 0) {
                this.fireEvent('ready');
                return false;
            }
            MODx.Ajax.request({
                url: Addon.config.connectorUrl
                ,params: {
                    action: 'mgr/item_master/getone'
                    ,id: this.config.item_id
                }
                ,listeners: {
                    'success': {fn:function(r) {
                        this.getForm().setValues(r.object);
    
                        var extendedfields = Ext.getCmp('addon-grid-extendedfields');
                        extendedfields.store.load(r.object.extendedFields);
    
                        Ext.get('addon-item-header').update('<h2>'+_('addon.item')+': '+r.object.item+'</h2>');
                        this.fireEvent('ready',r.object);
                        MODx.fireEvent('ready');
                    },scope:this}
                }
            });
        }


    I have tried store.load and store.loadRawData, neither work.