开发者

How to reload the Jsonstore results onto panel?

I am able to create a json response like this:

{
  "total": 2,
  "results": [{
    "id": 1,
    "checkList": "Item1",
    "checkStatus": "Available"
  }, {
    "id": 2,
    "checkList": "Item2",
    "checkStatus": "NoStock"
  }]
}

I have also created a f开发者_运维技巧unction and embed it to the listener on the Jsonstore. The function will loop through the available results and embedding in panels (called stockpanel1, stockpanel2, etc) and adding them to the main panel:

mainpanel.add(stockpanel);

I wish to a taskrunner to reload and grab the json result on every 10 seconds. And I would like to know how to update the new json results to the stockpanels on every 10 seconds? Do I need to add or remove the stockpanels or otherwise?

Thanks.


You've got the right idea. Upon load of the data, re-populate the panel. So, when that JsonStore is initialized, you want to kick off your taskrunner.

This function will run every 10 seconds, reloading the store. (untested)

var taskrunner = function(store) {
  store.reload();
  taskrunner.defer(10*1000, this, [store]);
}
taskrunner(Ext.getCmp('jsonstore'));

The JsonStore's 'load' event should call

mainpanel.removeAll();

before adding the new stockpanels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜