extjs4 - Reusing or creating new Store - ExtJS 4 -
i have several stores in application. not created until load grid should phone call store.load() function. components may have need of stores still not created. using function prepare problem:
getorcreatestore: function(storeid, classname){ homecoming (ext.getstore(storeid) == undefined) ? ext.create(classname) : ext.getstore(storeid); },
so each time component has need of specific store, phone call if created or create if doesn't exist.
is there improve way create stores don't have manually it? there configurations have missed set in extjs 4 application regarding creation of stores?
why utilize above prepare grids remain empty if store not created first.
see http://docs-origin.sencha.com/extjs/4.2.2/#!/api/ext.data.storemanager
you not giving storestoreid
when creating it. your ternary can condensed ||
operation. code
getorcreatestore: function(storeid, classname){ homecoming ext.getstore(storeid) || ext.create(classname, {storeid: storeid}); }
side note: consider ext's managers bad practice. nil more glorified global variables. prefer pass around stores they're needed rather resorting adding them global state. however, understand makes programming easier in cases, , if want lazy loading of stores (which i'm not sure benefit much), way go. i'm warning tends create maintenance , unit testing harder.
extjs extjs4 extjs4.2
No comments:
Post a Comment