Solution for uninitialized store used by columns in extjs grid

When using extjs to develop grid, if the editor of a column is store, and the list data is loaded when the store has not finished loading, it may appear

The problem that the column does not display is as follows

{
    header: '站点', dataIndex: 'stationId', flex: 1,
    renderer: function (value) {
        var store = stationStore;
        var record = store.queryBy(function (rec) {
            if (rec.data.code == value) {
                return true;
            }
        }, this);
        if (record.getCount() == 1) {
            return record.get(0).data.name;
        }
    },
    editor: {
        columnWidth: 1,
        xtype: 'combobox',
        typeAhead: true,
        editable: true,
        queryMode: 'local',
        valueField: "code",
        displayField: 'name',
        forceSelection: true,
        store: stationStore
}
},
When the page is loaded for the first time, the problem that the column is not displayed is prone to occur. The solution is as follows
First set the list's store autoLoad: false
After the store used in the column is loaded, call list.getStore().reload().
var coalTypeStore = Ext.create('Ext.data.Store', {
    autoLoad: true,
    fields: [{name: "name", type: "string"},
        {name: "code", type: "string"}],
    proxy: {
        // async: false,
type: 'ajax',
        url: ',
        reader: {
            type: 'json',
            root: 'records'
}
    },
    listeners: {
        'load': function () {
            if (stationStore.getCount() > 0) {
//Whether other stores are loaded
                Ext.getCmp('xx').getStore().load();
            }
        }
    }
});

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326994421&siteId=291194637