在Sencha Touch应用程序中自动刷新列表 [英] Auto Refresh the List in Sencha Touch Application

查看:64
本文介绍了在Sencha Touch应用程序中自动刷新列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个简单的聊天应用程序,单击刷新"按钮时可以查看更新的数据,但是可以定期从服务器刷新数据(因为我的聊天记录已远程存储在数据库中)

I am developing an simple Chat Application, I can view the updated data when I click on the REFRESH Button, BUT can I refresh the data at a regular interval from the Server (as my Chat is getting Stored in the Database remotely)

提前谢谢.

推荐答案

使用 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(); 

这应该适合您的情况.

这篇关于在Sencha Touch应用程序中自动刷新列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆