最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

php - Automatic update with new data on ext.data.store - Stack Overflow

programmeradmin3浏览0评论

I have this extjs data store

    mystore= Ext.create('Ext.data.Store', {
        id: 'store_id',
        fields: ['label', 'value', 'id', 'type'],
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'url/to/controller',
            reader: {
                type: 'json',
                root: 'MyModel'
            }
        }
    });

Is it possible with extjs configuration to make this store send ajax requests for new data on some interval (example 5 secs) automatically?

I want to use all functionality that extjs can provide so that I don't use php or additional javascript.

I have this extjs data store

    mystore= Ext.create('Ext.data.Store', {
        id: 'store_id',
        fields: ['label', 'value', 'id', 'type'],
        autoLoad: true,
        proxy: {
            type: 'ajax',
            url: 'url/to/controller',
            reader: {
                type: 'json',
                root: 'MyModel'
            }
        }
    });

Is it possible with extjs configuration to make this store send ajax requests for new data on some interval (example 5 secs) automatically?

I want to use all functionality that extjs can provide so that I don't use php or additional javascript.

Share asked Oct 9, 2012 at 8:34 VladVlad 2,7737 gold badges52 silver badges106 bronze badges 1
  • 1 you could also look at server side push, such as websockets or et – Neil McGuigan Commented Oct 9, 2012 at 15:12
Add a ment  | 

2 Answers 2

Reset to default 7

You can use the TaskManager class to help with recurring tasks.

var task = {
    run: function() {
        mystore.load();
    },
    interval: 5000
}

// This will reload your store every 5 seconds
Ext.TaskManager.start(task);

// Call when you want to stop polling the server
Ext.TaskManager.stop(task);

Inside of my grid code, i've put the function below and it worked:

setInterval(function() // IN YOUR CASE, IT RELOADS EACH 5 SECONDS
{
    storeReload = Ext.getStore("YourStoreHere");
    storeReload.load();
}
,5000);

I hope that have helped!!

发布评论

评论列表(0)

  1. 暂无评论