views:

25

answers:

1

Hi:

I have serveral extjs components in my page, the chart, gird ,formPanel and ect, and now I meet some problems about the refresh of them, take the gridPanle for exmaple:

This is the grid codes:

var myStore=new Ext.data.JsonStore({
  autoLoad:true,
  fields:['name','age'.....]
});

var grid = new Ext.grid.GridPanel({
  stroe:myStore,
  colums:myColumns
  //....other config
});

When the reload event of the stroe if acted(Triggered by user),the store will get new data from the server side, the the grid panel refresh, this is fine,

however sometimes the data from the server is null(for example, there is not data found according to the request from the client),if so, the grid panel also hold the data of last requst,

how to make the grid refresh (show nothing) and show something to user that no data found?

So are other components in my page,most are some charts.

I have thought use add a handler to handle the event of the refresh of the component,before it refresh, check the store, if the store is null, then do something,howeverI found that I can not get the store of a component,also their event are different,for eample:

For the GridPanle,there is a event of beforerender

http://dev.sencha.com/deploy/dev/docs/?class=Ext.grid.GridPanel

FOr a chart, there is a event of beforerefresh

http://dev.sencha.com/deploy/dev/docs/?class=Ext.chart.Chart

So use the render or refresh??

Any ideas?

+1  A: 

a "null" response from the server should generally be considered an error.

In your grid example, if nothing matches, there should be some representation of a record set with zero records. For a typical JsonStore, the response should look like this:

{ total:0, items:[] }

(assuming a totalProperty of "total", and a root of "items")

That way, it's still a valid response (even if it's not null).

If your server is sending back "null", or an empty raw response (a zero-length string), JsonReader doesn't know how to handle it, and errors or bails.

timdev