如何检查dojo.datagrid加载完成?

发布于 2024-10-26 16:19:15 字数 397 浏览 6 评论 0 原文

我的其中一个页面中有一个 dojo.datagrid 。 Datagrid 及其存储(通过调用 URL)是通过声明性方法创建的。不是通过动态/程序化。

我需要执行一个 javascript 方法,该方法在我的数据网格下方显示一个 div(需要来自数据网格的少量数据)。我应该仅在数据网格加载完成后显示 div;而不是在此之前。

我正在寻找诸如数据网格 onload 完成之类的事件。 dojo.datagrid 有什么活动吗?我在 dojo.Datagrid 文档的事件列表中没有看到它。

有没有办法检查 dojo datagrid onload 是否完成?

有没有办法使用 dojo.connect 来处理这个问题?

如果我们有什么办法可以做到这一点,请告诉我...

谢谢, 拉杰.

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

感性不性感 2024-11-02 16:19:15

数据网格本身从未真正加载所有可用数据,它仅显示其存储中数据的子选择。

您需要绑定商店事件才能捕获 onload 事件。由于存储可以从很多地方加载数据,因此您需要将 onComplete 函数传递给网格存储的 fetch 方法。

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

您还可以以编程方式创建存储,使用 onComplete 侦听器调用 fetch,并在完成对存储的 onComplete 侦听器中的项目的修改后,调用 myGrid.setStore(myStore);

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);

誰ツ都不明白 2024-11-02 16:19:15

DataGrid 有一个事件 _onFetchComplete,您可以使用 dojo.connect 连接到该事件。请注意,它以 _ 开头,因此它应该是一种私有/受保护的事件,并且其行为可能会在较新的 Dojo 版本中发生变化。我知道它在 Dojo 1.6 中运行良好。

The DataGrid has an event _onFetchComplete which you could connect to with dojo.connect. Note that it starts with _ though, so it's supposed to be a private/protected kind of event and its behaviour could change in newer Dojo versions. I know it works well in Dojo 1.6.

优雅的叶子 2024-11-02 16:19:15

正如 Alex 已经指出的那样,您可以对(不幸的是)私有 _onFetchComplete 事件做出反应。在 dojo 1.7 中,这可以通过 dojo.aspect 来实现,例如:

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

As Alex already pointed out, you can react 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...    
    });
});
奶气 2024-11-02 16:19:15

您可以设置一个计时器来检查数据是否已加载,每隔一秒左右运行一次,直到加载完成(setSelectedIndex 将返回 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!
}

You can set up a timer to check if the data is loaded, run every second or so until the load 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!
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文