PDA

View Full Version : Grid onStoreLoad and custom renderer - optimisation



michall
21 Dec 2011, 4:08 PM
Hello,

I have a Ext.grid.Panel with columns renderer defined. Since renderer function is quite heavy now, I'm thinking about some optimisation. Im trying to get some code outside renderer. Just got idea to keep workflow this way:
store load
heavy operations on store data (once! not on every renderer call)
cell rendering using data calculated in 2 point
and I have a problem because renderer is called too early, before store load event. Grid "onRender" is too early because store is still empty... I have no other ideas...

Thanks for advice

mitchellsimoens
21 Dec 2011, 4:19 PM
Have you thought about the convert method on the model fields?

michall
22 Dec 2011, 1:53 AM
These operations are strongly connected with view, so I can't do this in convert method in model. Rather I would like to inject in rendering - data loading process like I said before.

michall
22 Dec 2011, 6:59 AM
After some research I found quite nice solution in call stack to renderer function (rendererCellFunction) declared for colum, this is whole stack from XHR request to rendering:


rendererCellFunction() <- my fct
prepareData() ext-all-debug.js (line 80338)
prepareData() ext-all-debug.js (line 78207)
collectData() ext-all-debug.js (line 60423)
callParent() ext-all-debug.js (line 2891)
collectData() ext-all-debug.js (line 78225)
refresh() ext-all-debug.js (line 60387)
callParent() ext-all-debug.js (line 2891)
refresh() ext-all-debug.js (line 69602)
callParent() ext-all-debug.js (line 2891)
refresh() ext-all-debug.js (line 78524)
callParent() ext-all-debug.js (line 2891)
refresh() ext-all-debug.js (line 78907)
onDataChanged() ext-all-debug.js (line 60603)
fire() ext-all-debug.js (line 10658)
continueFireEvent(eventName="datachanged" ...) ext-all-debug.js (line 13854)
fireEvent(eventName="datachanged") ext-all-debug.js (line 13834)
loadRecords() ext-all-debug.js (line 45548)
onProxyLoad() ext-all-debug.js (line 45295)
processResponse() ext-all-debug.js (line 25895)
createRequestCallback() ext-all-debug.js (line 26086)
callback() ext-all-debug.js (line 5283)
onComplete() ext-all-debug.js (line 18241)
onStateChange() ext-all-debug.js (line 18192)
(?)() ext-all-debug.js (line 1537)


After "datachanged" I have full whole store data ready for doing "my stuff" and pass results to renderer. So basically I'm watining for datachanged event on my store, doing stuff and use results in rendering function - 1/3 less time spent on rendering B) I think this might be a separate event for view, dedicated for doing stuff before cell rendering begins.