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

29 Jan 2007, 2:16 PM

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:


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?



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.

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




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?

9 Apr 2007, 3:55 AM
Try this:


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(); }