javascript - extjs4 mvc event debugging inconsistent results -
i have grid.panel inside of viewport binded store. once grid (or store) loaded, @ value in first row (or row), , if it's false, hide column in grid. i've tried many different events, here's example in controller:
ext.define('helperbatchform.controller.batchcontroller', { extend: 'ext.app.controller', stores: [ 'batches' ], models: [ 'batch' ], views: [ 'batch.batchgrid', 'batch.batchedit' ], init: function () { this.control({ 'batchgrid': { itemdblclick: this.editbatch ,viewready: this.ongridload } }); }, ongridload: function(grid){ stop; },
"stop" throws error , opens debugger in ie browser. on browser can see grid, , rows, rendered. in debugger, can @ grid.store.data.items[0] , see first row. seems well, , should able put condition in function based on data hides grid. doesn't work - here things start weird.
if replace "stop;" "debugger;", , reload, time visual studio debugger. now, in ie screen, can see grid headers, , none of data. , grid.store.data.items empty array. instant resume, see full grid.
but that's not all. if function is: ongridload: function (grid) { alert('ongridload'); debugger; }, now, visual studio debugger loaded, can see full grid , data in ie. , grid.store.data.items[0] gives me first row. if replace "debugger" conditional code, works! in other words, have code doesn't work, starts working if throw alert() before it.
to summarize, code below hide column:
ongridload: function (grid) { alert('ongridload'); if (grid.store.findexact('is_rcm', false) >= 0) { grid.columns[6].hide(); } },
but if alert commented out, not hide column.
any ideas or explanations why might appreciated.
my guess issue here related async loading of store. seeing race condition of split second between view ready store not yet populated. in quantum physics observation of event changing outcome :)
my suggestion put load listener on store instead , inject processing @ point.
Comments
Post a Comment