PDA

View Full Version : Grid panel with JSON store | loading problem



waqasrazzaq
29 Dec 2010, 2:22 AM
Hello all,

I have a grid panel with JSON store.

Is there any event which tells that no data is returned in response of request, As Store "Load" event which tells that data is loaded, but what to do if no data comes in response. Actually i want to perform some actions if no data in response.

Thanx in Advance..

aramaki
29 Dec 2010, 2:34 AM
store.on('load',function(store,records){
records.length = 0 ? ... : ...
})

waqasrazzaq
29 Dec 2010, 2:51 AM
The main reason is "Load" event is not calling when the records are 0. Above solution is the latter thing.

waqasrazzaq
29 Dec 2010, 3:08 AM
Jsonstore does not call "Load" event in case of content is null. But i want to perform some actions in case of Content is Null in response. How can we identify this.. :(

Condor
29 Dec 2010, 4:17 AM
The load event is called when there are no records (but your server does needs to return an empty array as the root instead of no root at all).

If the server response isn't valid (like having no root) then the 'exception' event is triggered.

waqasrazzaq
29 Dec 2010, 5:15 AM
Yes i Agreed that server should return the empty array as a root, But i stuck in such a scenario where server could not do like this :( .
and server response is valid means there is no exception, except returning NULL in response.

Can we not do any workaround for this situation.

Condor
29 Dec 2010, 5:24 AM
Yes, you would write a root function for your reader, e.g.

Instead of

root: 'myroot'
use:

root: function(v) {
return v.myroot ? v.myroot : [];
}