Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Data not displaying in ListGrid

    1. SmartClient Version: v9.0p_2013-07-25/LGPL Development Only (built 2013-07-25)

    2. IE 9.0.8112.16421

    3. Non-server issue

    5. No JavaScript error

    I could use some help diagnosing a problem I'm running into trying to migrate for 3.1 to 4.0.

    I have a case where I am manually loading data into a ListGrid. The code looks similar to this:

    Code:
    final ListGridSetData listGrid = new ListGridSetData();
    listGrid.setEmptyMessage("Loading...");
    List<ListGridRecord> recordList = new ArrayList<ListGridRecord>();
    for (int i = 0; i < 10; ++i) {
      ListGridRecord record = new ListGridRecord();
      record.setAttribute("Col1", "Row" + i + " Col1");
      record.setAttribute("Col2", "Row" + i + " Col1");
      recordList.add(record);
    }
    
    ListGridRecord[] records = new ListGridRecord[recordList.size()];
    recordList.toArray(records);
    listGrid.setData(records);
    listGrid.setEmptyMessage("No items to show");
    After this completes, the grid shows the message "No items to show" as if there is no data in the grid. I've added a button to my code with a click handler and in the click handler I display the number of records in the grid. The display shows 10 (even though the grid is still showing "No items to show").

    My actual code is a lot more complex than this (e.g., lots of custom options/settings no the grid, using a derivation of ListGridRecord for the records, data filled in after async call to a server, etc.). I've tried stripping this down to a simple example to show what is happening, but the simple example works fine.

    Can you point me to any information or tools that might help identify what is causing the grid in my more complex case to display the empty message instead of the data?

    In addition, the documentation on setData is confusing. It says that it can only be called from the constructor (which I am not doing), and if you are doing this outside of the constructor you should call the method setData instead. This make no sense because that is the same method. Is the documentation about what to do after the constructor referring to the incorrect method name? What should I use instead?

    We've been using this same code in a shipping product for almost 2 years and it has been working fine until I tried to roll from 3.1 (from last November) to 4.0.

    #2
    This isn't a condition we've ever seen arise.

    There are basically just two conditions that cause the empty message to be displayed:

    1. there are no records

    2. there are no fields

    Maybe #2 is the issue here?

    Or perhaps you have a call setData() that provides an empty set of Records, and that's being called unexpectedly.

    About the docs for setData() - we'll clarify that. It's a direct translation of some SmartClient docs (where it makes sense - different component lifecycle).

    Comment


      #3
      Thanks for the hint. This has helped narrow it down, but there is still something strange happening. I have a lot of code around this and I have not been able to repro this in a simple example, but the issue seems to be that there are no fields.

      In my code I set the fields as follows:
      Code:
      listGrid.setFields(fields);
      listGrid.setSort(sortSpecifiers);
      (There are actually a lot of lines of code and some if tests in between dealing with view state, but in this case these are the only two lines executed in the method besides the if tests).

      If I set a break point on the setSort() call, and I have an expression watch on the value of listGrid.getAllFields(), it shows that there is one field. If I step over the setSort() call, the expression window then shows the result of getAllFields() being null.

      If I set my break point much earlier in the code and step through everything leading up to this point, the the code works fine.

      Any ideas on how to narrow this down further?

      Comment


        #4
        Are you re-using some of the same Array[]s or Lists in calls to setFields() and other calls?

        Comment


          #5
          No, I new'ed them up right before setting them on the grid. They are stored in variables local to the method and never reused.

          Comment


            #6
            We're just not seeing any code that gets executed in setSort() that could affect the fields Array.

            If you're not comfortable stepping into framework code (which is understandable - takes a lot more knowledge), we'd recommend trying to disable more of more of your other logic until you isolate whatever setting or call is causing this strange effect.
            Last edited by Isomorphic; 1 Aug 2013, 15:24. Reason: typo

            Comment


              #7
              OK, I narrowed it down some by debugging through the JavaScript.

              It is not the setSort() method that is causing the problem (at least not directly). The setSort() fires the FieldStateChanged event. I have a handler registered for this event which calls refreshFields (for reasons I won't go into unless you need me to). The first thing refreshFields does is call setFields(this.completeFields). At this point the "completeFields" value is undefined. If you delay the call to refreshFields until after the control is drawn it works. I'm not certain what is going on with the "completeFields" property on the grid.

              The attached code demonstrates the problem. If you comment out the call to refreshFields the example works. The documentation on refreshFields does not say anything about there being restrictions about when it can be called.
              Attached Files
              Last edited by pgrever; 1 Aug 2013, 16:55.

              Comment


                #8
                We've made changes to address this - please retest with a build dated August 6 or later

                Comment


                  #9
                  Re-tested... Looks good now. Thanks.

                  Comment

                  Working...
                  X