how to check dojo.datagrid loading completed?

Raj picture Raj · Mar 26, 2011 · Viewed 10.1k times · Source

I have a dojo.datagrid in one of my pages. Datagrid and its store(by calling an URL) are created by declarative method. not by dynamic/programmatic.

I need to execute a javascript method which displays a div(which requires few data from the datagrid) just below my datagrid. I should display the div only after my datagrid loading completed;not before that.

I am looking for event like onload completed for datagrid. Is there any event do we have with dojo.datagrid? I don't see it in the event's list of dojo.Datagrid documentation.

Is there a way to check dojo datagrid onload completed?

Is there any way to use dojo.connect to handle this?

Please let me know if we have any way to do this...

Thanks, Raj.

Answer

Tom Gruner picture Tom Gruner · Mar 29, 2011

The datagrid itself never actually loads all of the data available, it is only showing a sub selection of the data in its store.

You will need to tie into the store events in order to catch the onload event. Since the store can load data from lots of places, you will need to pass an onComplete function to the fetch method of the grid store.

grid.store.fetch({onComplete : function (items) { // Do something }});

You could also create the store programatically, call fetch with your onComplete listener, and once you have finished the modification of the items in the store's onComplete listener, call myGrid.setStore(myStore);