user1713114
user1713114

Reputation: 19

Extjs - Add item to store manually

I want to manually add items to a combo box.

Ext.define('MyApp.store.myStore', {    extend: 'Ext.data.Store',
requires: [
    'Ext.data.Field'
],

constructor: function(cfg) {
    var me = this;
    cfg = cfg || {};
    me.callParent([Ext.apply({
        storeId: 'myStore',
        fields: [
            {
                name: 'nameField'
            }
        ]
    }, cfg)]);
}
});

.

onfocus: function(component, e, eOpts){
    var comp = component.up('#viewContainer');
    var tgrid = comp.down('#netTable');
    console.log(component);
    var arr = tgrid.store.collect('dbColumn');
    //alert(arr);
}

I want to add arr, which an array of data , to the store. How do I go about it

I tried the following, but it didn't work

var store =  Ext.getStore('myStore');
var menuPoint = Ext.create('Sencha.model.MenuPoint', 
   {
        nameField: 'child'
    });
store.add(menuPoint);

Upvotes: 0

Views: 10645

Answers (1)

lmno
lmno

Reputation: 1044

Try something like this:

var store =  Ext.getStore('myStore');
var menuPoint = Ext.create('Sencha.model.MenuPoint', 
   {
        nameField: 'child'
    });
store.loadData(menuPoint,true);

The second parameter to loadData() is the key. Setting it to true tells the store to append this record to the existing set of records already in there.

Upvotes: 1

Related Questions