Agile toolkit : how to automatically reload grid

Deadly 提交于 2019-12-11 03:48:52

问题


Using Agile toolkit to generate a grid, I'm trying to get an automatic reload of a grid but I can't figure how :/

I dug into the js() function and saw the first parameter is $when but, how to set up an interval?

Reload on event like button click is ok, but I need to set up reload every x sec.


回答1:


OK here is complete tested example how you should do.

First I have to admit, that ATK4 had no setInterval and clearInterval functions added in univ() library, but already had setTimeout. I added setInterval and clearInterval and made pull request in Github (https://github.com/atk4/atk4/pull/173). I hope Romans will accept that, but if not, then you can always add these functions in your own JS library.

So here is the code:

$g = $this->add('Grid');
$this->js(true)->univ()->setInterval(
    $g->js()->reload()->_enclose()
,3000);

Or you can even execute multiple independent functions like this:

$this->js(true)->univ()->setInterval(
    $g->js(null,array(
        $g->js()->reload(),
        $g->js()->univ()->successMessage('Reloaded...')
    ))->_enclose()
,3000);

Key part here is ->_enclose() method which will convert your JS chain to anonymous JS function.




回答2:


Javascript code :

setInterval("func()",1000);

This will call the func() function every 1000 ms



来源:https://stackoverflow.com/questions/13567634/agile-toolkit-how-to-automatically-reload-grid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!