PDA

View Full Version : Strange grid behavior with empty JSON data



DrZog
17 Apr 2007, 6:19 AM
When I update a grid using:


ds.reload();

everything works fine as long as the server returns at least one value. When the php script returns a zero result like:


{"allProps":null,"totalCount":"0"}

the grid is not updated to reflect the situation i.e. an empty grid with zero records

This is a problem as I'm using one grid as a pre-filter for a second grid so stale records are left in the second grid if the first grid returns a null result.

Incidentally this seems to be the default behaviour for Jeff Howden's excellent Paged Grid Filter Field, http://extjs.com/forum/showthread.php?t=2758.

Any ideas?

tryanDLS
17 Apr 2007, 6:53 AM
When you return 0 records, you should still return an empty array, not a null.

DrZog
17 Apr 2007, 7:37 AM
Thanks Tim, makes sense. However I still have the empty rows in the grid which are 'selectable'. What I would like to achive is getting the grid to 'collapse'

My server response is now:


{'allProps':[{}], 'totalCount':0}

Not sure thats what you meant by an empty array

tryanDLS
17 Apr 2007, 7:56 AM
{"allProps":[[]],"totalCount":"0"}
Not sure thats what you meant by an empty array

I think that should be

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

If you want the grid to collapse, you'd have to check for rowcount=0 in your 'load' handler, and then modify your display. Hide the grid, pop up a messagebox, etc.

DrZog
17 Apr 2007, 7:58 AM
OK got it:


{'allProps':[], 'totalCount':0}

Thanks again for the tip Tim

js should come with a health advisory :((

boycrazy4love
26 Dec 2007, 12:45 AM
{'allProps':[], 'totalCount':0} How can I response like this ???
Please show me your sample code :)=P~

tryanDLS
26 Dec 2007, 9:23 AM
You don't know how to write PHP, ASP, C# (or whatever language you're coding in) to send a string response??

boycrazy4love
26 Dec 2007, 7:20 PM
I'm have solve this problem Thanks ! :)