javascript - Sencha Touch 2-How to removeAll() in a controller from a store in a view? (SOLVED) -
i want use function removeall() of stores in controller, delete content of store in view.is possible? here code:
my view:
ext.define('demoapp.view.mainmenu',{ extend:'ext.form.panel', requires:['ext.titlebar','demoapp.store.ccaa'], alias:'widget.mainmenuview', config:{ layout:{ type:'fit' }, items:[{ xtype:'fieldset', items:[{ xtype:'titlebar', title:'menĂº principal', docked:'top', items:[{ xtype:'button', text:'desconectar', itemid:'logoffbutton', align:'right' }] }, { xtype:'fieldset', items:[{ xtype:'selectfield', itemid:'ccaacombo', label:'comunidad autonoma', store:'storeccaa', displayfield:'nombre', valuefield:'id', autoselect:false, placeholder:'elige una para filtrar' }] } ] }], listeners:[{ delegate:'#logoffbutton', event:'tap', fn:'onlogoffbuttontap' }, { delegate:'#ccaacombo', event:'change', fn:'onccaacombochange' }] }, onlogoffbuttontap:function(){ this.fireevent('onsignoffcommand'); }, onccaacombochange:function(field,value){ console.log("estoy en la vista"); var idccaa=value; console.log(idccaa); this.fireevent('onccaacombochangeaction',idccaa); } });
my controller:
ext.define('demoapp.controller.mainmenu',{ extend:'ext.app.controller', config:{ refs:{ loginview:'loginview', mainmenuview:'mainmenuview' }, control:{ mainmenuview:{ onsignoffcommand:'onsignoffcommand', onccaacombochangeaction:'onccaacombochangeaction' } } }, //transicion getsliderighttransition: function () { return { type: 'slide', direction: 'right' }; }, //funciones onsignoffcommand:function(){ var me=this; ext.viewport.animateactiveitem(this.getloginview(),this.getsliderighttransition()); }, onccaacombochangeaction:function(idccaa){ console.log("estoy en el controlador"); console.log(idccaa); } });
in controller,after line var me=this in onsignoffcommand:function() want use removeall() function of store:'storeccaa' of view.
add refs
selectfield in controller
ext.define('demoapp.controller.mainmenu',{ extend:'ext.app.controller', config:{ refs:{ loginview:'loginview', mainmenuview:'mainmenuview', mainmenuviewselectfield: 'mainmenuview selectfield#ccaacombo' }, control:{ mainmenuview:{ onsignoffcommand:'onsignoffcommand', onccaacombochangeaction:'onccaacombochangeaction' } } }, //transicion getsliderighttransition: function () { return { type: 'slide', direction: 'right' }; }, //funciones onsignoffcommand:function(){ var me=this; // store of select field , remove records this.getmainmenuviewselectfield().getstore().removeall(); ext.viewport.animateactiveitem(this.getloginview(),this.getsliderighttransition()); }, onccaacombochangeaction:function(idccaa){ console.log("estoy en el controlador"); console.log(idccaa); } });
Comments
Post a Comment