2012-07-30 44 views
0

我有以下的店铺:清除数据存储和重新填充它

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' 
     }] 
} 
}); 

它采用以下模式:

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'} 
    ] 
} 
}); 

在代码中有些地方我动态添加菜单点是这样的:

有时我需要清除商店,ergo删除我动态添加的菜单点,只使用m在商店中硬编码的enu点。我看到了在商店中删除和添加的方法,但我不知道如何重置商店并使用我在那里定义的静态数据重新填充商店。

回答

1

做,因为我已经回答了你的问题上一张,你不尊重:)

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()函数清理分组数据

干杯,奥列格

+0

再次谢谢奥列格,你一遍又一遍地保存我的一天)) – 2012-07-30 10:11:38

相关问题