2012-03-14 68 views

回答

8

使用DelayedTask类煎茶触摸的:

//create the delayed task instance with our callback 
var task = Ext.create('Ext.util.DelayedTask', function() { 
    //load the list's store here. The list will be automatically updated 
    listComp.getStore().load(); // Assuming your list component is "listComp" 
    listComp.refresh();  

    // The task will be called after each 10000 ms 
    task.delay(10000); 
}, this); 

//The function will start after 0 milliseconds 
//so we want to start instantly at first 
task.delay(0); 

//to stop the task, just call the cancel method 
//task.cancel(); 

这应该为你的情况下工作。

+0

谢谢。试了一下,并在建议的片段中进行了一些调整,使我的工作得到了正确执行。谢谢.... – 2012-03-26 10:43:13

+0

我已经做了上面的例子任务。任务在主控制器中初始化,但切换到另一个视图后,正在运行的任务被取消。我是否需要添加其他特定配置? – 2013-02-20 11:06:45

+0

Peter O.任务只会在你放入task.cancel(); 试着看看这里的例子。 (http://www.sencha.com/forum/showthread.php?194202-Autorefresh-List-with-DelayedTask)它对我来说很好。我想你也会。 – 456qwe123asd 2013-10-24 13:04:05

0

你只需要在正常的权利调用你的refresh()函数?

所以你只需要在你的refresh()函数的末尾添加一个setTimeout("refresh()", 1000);。然后你只需要在你的应用程序启动时调用它。

希望这有助于

+0

你好,让我把这个添加到我的代码中,如果我需要任何进一步的帮助,我会回复给你。谢谢... – 2012-03-14 07:44:35

0

也许您会对聊天应用程序中的套接字服务器连接感兴趣。每当服务器数据发生变化时,服务器都会通知客户看看http://socket.io/

相关问题