How to check dojo.datagrid download is complete?

I have dojo.datagrid on one of my pages. Datagrid and its storage (by calling the URL) are created using the declarative method. not dynamic / software.

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

I am looking for an event like onload for a datagrid. Is there any event with dojo.datagrid? I do not see it in the dojo event list. Datagrid Documentation.

Is there a way to check if a datagrid dojo has finished loading?

Is it possible to use dojo.connect for this?

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

Thanks, Raj.

+4
source share
4 answers

The datapack itself never downloads all available data, it only shows a sub-selection of data in its repository.

You need to bind store events to catch the onload event. Since the store can load data from a large number of places, you need to pass the onComplete function to the fetch method in the grid store.

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

You can also create the repository programmatically, invoke fetching using your onComplete listener, and as soon as you finish modifying the items in the onComplete store, call myGrid.setStore (myStore);

+5
source

There is a _onFetchComplete event in the DataGrid that you could connect to with dojo.connect . Note that it starts with _ , although it must be a private / protected kind of event, and its behavior may change in newer versions of Dojo. I know that it works well in Dojo 1.6.

+3
source

As Alex already pointed out, you can respond to the (unfortunately) private _onFetchComplete event. With dojo 1.7, this can be achieved with dojo. Aspect like:

 require(["dojo/aspect", "dojox/grid/DataGrid", ...], function(aspect, DataGrid, ...) var myGrid = new DataGrid({ ... }); aspect.after(myGrid, "_onFetchComplete", function() { // Do something with myGrid... }); }); 
+3
source

You can set a timer to check if the data is loaded, run every second or so until the download is complete (setSelectedIndex will return true):

 private var load_check:uint; /* start the interval timer when the app is initialized */ protected function init ():void { load_check = setInterval(getTime, 500); // 1/2 second } private function getTime():void { if ( !datagrid.setSelectedIndex (0)) return; clearInterval(load_check); // data loaded! } 
0
source

Source: https://habr.com/ru/post/1345298/


All Articles