How to determine if a dojo grid has finished loading?

我们两清 提交于 2019-12-06 08:49:37

Here is a great answer that I found:

grid.connect(grid, '_onFetchComplete', function(){
    for(var i in grid._pending_requests){
        if(grid._pending_requests[i]){
           return; //no, something's not loaded yet.
        }
    }
    //okay, nothing is on the fly now.
});

http://dojo.6188.n7.nabble.com/function-when-the-dataGrid-is-ready-td37563.html

dojox.grid.DataGrid has an internal flag that gets set in _onFetchComplete, so you could try

var grid = ...
if (grid._isLoaded) {
    ...
}

I found this question because I was looking for the same thing. The closest I can get is to wait for Dojo's Loading Message to disappear (if the grid loads fast, it's hard to see). Here is what I use right now:

/** Required imports **/
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.By;

/** Code snippet **/
WebDriver driver = new FirefoxDriver();
WebDriverWait wait = new WebDriverWait(driver, /* Max wait time */ 30);
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector(".dojoxGridLoading"));

This gets me really close.

This is a solution using non-internal event "onStyleRow":

// Declare myGridLoaded
var myGridLoaded = false;
...
...
// Connect onStyleRow:
dojo.connect(grid, "onStyleRow", grid, function(row) {
    if(!myGridLoaded) {
        doYourStuff();
        // Make sure it runs only once:
        myGridLoaded = true;
    }
});
// Now set your store and the handler will run only once 
// when the first row is styled - if any:
grid.setStore(store);
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!