Ext 4.1.1: Add new record to Store

后端 未结 2 2058
余生分开走
余生分开走 2021-01-05 03:49

I would like to add records after the initialization of a store.

I tried loadData(), loadRawData(), add() but nothing seams to work.

Here is my jsfiddle: htt

2条回答
  •  被撕碎了的回忆
    2021-01-05 04:24

    You need to set queryMode: 'local' in the combo box. Minimal example:

    Ext.onReady(function() {
        var store = Ext.create('Ext.data.Store', {
            alias: 'store.ModeStore',
            autoLoad: false,
            fields: [{
                name: 'mode',
                type: 'string'
            }, {
                name: 'id',
                type: 'string'
            }],
            data: [{
                mode: 'mode1',
                id: 1
            }]
        });
    
        var container = Ext.create('Ext.form.field.ComboBox', {
            renderTo: Ext.getBody(),
            displayField: 'mode',
            valueField: 'mode',
            store: store,
            queryMode: 'local'
        });
    
        store.add({
            mode: 'mode2',
            id: 2
        });
    }); 
    

提交回复
热议问题