tags:

views:

347

answers:

1

Hi,

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 function 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.

A: 

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.

Jonathan Julian
Thanks Jonathan. It works well. Now I understand why it's not working for me previously, as I had the remove panel within the taskrunner instead of the 'load' event function.
jl