Results 1 to 8 of 8

Thread: Strange grid behavior with empty JSON data

  1. #1
    Ext JS Premium Member DrZog's Avatar
    Join Date
    Mar 2007
    Location
    Bristol, UK
    Posts
    197

    Question Strange grid behavior with empty JSON data

    When I update a grid using:

    Code:
    ds.reload();
    everything works fine as long as the server returns at least one value. When the php script returns a zero result like:

    Code:
    {"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?

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    When you return 0 records, you should still return an empty array, not a null.

  3. #3
    Ext JS Premium Member DrZog's Avatar
    Join Date
    Mar 2007
    Location
    Bristol, UK
    Posts
    197

    Default

    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:

    Code:
    {'allProps':[{}], 'totalCount':0}
    Not sure thats what you meant by an empty array

  4. #4
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    Code:
    {"allProps":[[]],"totalCount":"0"}
    Not sure thats what you meant by an empty array
    I think that should be
    Code:
    {"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.

  5. #5
    Ext JS Premium Member DrZog's Avatar
    Join Date
    Mar 2007
    Location
    Bristol, UK
    Posts
    197

    Default

    OK got it:

    Code:
    {'allProps':[], 'totalCount':0}
    Thanks again for the tip Tim

    js should come with a health advisory

  6. #6

    Default

    {'allProps':[], 'totalCount':0} How can I response like this ???
    Please show me your sample code

  7. #7
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854

    Default

    You don't know how to write PHP, ASP, C# (or whatever language you're coding in) to send a string response??

  8. #8

    Default

    I'm have solve this problem Thanks !

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •