Reputation: 4545
I have the following store:
Ext.define('Sencha.store.AdultMenuStore', {
extend: 'Ext.data.Store',
config: {
onItemDisclosure: true,
model:'Sencha.model.MenuPoint',
data: [
{
id: 'addChild',
name: 'Add child',
icon_url: 'http://kidsparent.no/images/adultMenu/bkids-home-plussign.png',
xtype: 'addchildform'
},{
id: 'share',
name: 'Share',
icon_url: 'http://kidsparent.no/images/adultMenu/bkids-home-shareicon.png',
xtype: 'childmenu'
},{
id: 'myProfile',
name: 'My Profile',
icon_url: 'http://kidsparent.no/images/adultMenu/bkids-home-profile.png',
xtype: 'childmenu'
},{
id: 'help',
name: 'Help',
icon_url: 'http://kidsparent.no/images/adultMenu/bkids-home-question.png',
xtype: 'childmenu'
}]
}
});
Which uses the following model:
Ext.define('Sencha.model.MenuPoint', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'id', type: 'string'},
{name: 'name', type: 'string'},
{name: 'icon_url', type: 'string'},
{name: 'xtype', type: 'string'}
]
}
});
Some places in the code I add menu points dynamically like this:
var child = children[i];
var menuPoint = Ext.create('Sencha.model.MenuPoint', {id: child.childId, name: child.firstName, icon_url: 'aLink', xtype: 'childmenu'});
store.add(menuPoint);
And sometimes I need to clear the store, ergo remove the menu points I added dynamically and only use the menu points I hardcoded in the store. I see methods for removing and adding in the store, but I dont know how to reset the store and repopulate it with the static data I defined there.
Upvotes: 0
Views: 1425
Reputation: 3870
do as I have answered on your prev question, which you did not respect :)
var data = [
{
id: 'addChild',
name: 'Add child',
icon_url: 'http://kidsparent.no/images/adultMenu/bkids-home-plussign.png',
xtype: 'addchildform'
},{
id: 'share',
name: 'Share',
icon_url: 'http://kidsparent.no/images/adultMenu/bkids-home-shareicon.png',
xtype: 'childmenu'
},{
id: 'myProfile',
name: 'My Profile',
icon_url: 'http://kidsparent.no/images/adultMenu/bkids-home-profile.png',
xtype: 'childmenu'
},{
id: 'help',
name: 'Help',
icon_url: 'http://kidsparent.no/images/adultMenu/bkids-home-question.png',
xtype: 'childmenu'
}]
store.load(function (store) {
store.add(data)// data is an array with you local data
})
store.load() function cleans up prev data
Cheers, Oleg
Upvotes: 1