PDA

View Full Version : JSONDatamodel Grid - {"totalCount":0}?



Wolfgang
29 Jan 2007, 2:16 PM
Hello,

using a grid with the JSONDataModel, when the result set is empty the grid is no longer responsive and the browser needs a reload for the page.
The Result for the empty dataset pushed to the grid via XHR looks like:


{"totalCount":0}


So totalcount is set, but of no data because the result set is empty.
So what to do if the result set is empty? Send an empty response, even without totalcount?
Will this be different/issue in the gridv2 / JSONDataModel in v0.40?

Regards

Wolfgang

tryanDLS
29 Jan 2007, 5:06 PM
You should still return an empty array as part of your response, unless you're going to code for this condition in you load handler or exception process.

Wolfgang
9 Apr 2007, 3:22 AM
Using a3-r4 i still cannot get it to work.
I tried the following JSON result:


{"totalCount":0,"data":[{"direction":""}]}


and


{"totalCount":0,"data":[""]}


Both examples result in the same: No error, but 1 record as response.
When debugging with FireBug, i could verify this.

So how would i return an empty result set, can anyone give an example of how the JSON should look like?

Arikon
9 Apr 2007, 3:55 AM
Try this:

{"totalCount":0,"data":[]}

Wolfgang
9 Apr 2007, 5:52 AM
Thank you - works like a charm :)

For those using php having a similar problem. Put this to your backend before doing the JSON encoding.


if ($result['totalCount'] == 0) { $result['data'] = array(); }