Announcement

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

    ListGrid selectRecord(0) does not work because the index is not zero based.

    SmartGWT 4.1d LGPL 2013-11-07

    Wanted to get this out there in the forum for others to see....

    In my DataArrivedHandler.onDataArrived method I was going crazy because ListGrid setRecord(0) or setSingleRecord(0) wasn't working.

    I later noticed the index is 1 based. setRecord(1) / setSingleRecord(1) selected the first item in the list.

    Thanks,
    -B

    #2
    This is not true, selection is zero-based. Something else was wrong with your code.

    Other users, please ignore this (incorrect) claim. Selection and row numbering in ListGrid is zero-based.

    Comment


      #3
      Ok, must be me...

      The server team built these custom data sources so it could be that.

      Comment


        #4
        Actually no....it's a bug

        The index of the first item in the list grid changes to 1 when you apply grouping (setGroupByField).

        When I commented that out the index of the first item went back to zero.

        Comment


          #5
          Again, rows have zero-based numbering. What you are observing is that, when grouped, the first row is a group node, which is not allowed to be selected.

          Comment


            #6
            Ok, I get that now that you've explained it, but it's not apparent when looking through the APIs and I think it's reasonable for a person to expect a grouping row to be segregated from the actual index of real records. The record at index 1 is still the first real record, but now the caller needs to manually account for grouping to select the first item. Granted I can hard code it, or run a quick test to see if a record came out of index zero, but perhaps a "selectFirstRecord" method may make sense here - one that takes grouping into account.

            Comment


              #7
              When records are grouped, they have a completely different order, and some are not shown at all (closed groups). There is no way to magically map between the indices while grouped and indices while not grouped and have the developer not have to worry about this at all. If you have the grouping feature enabled in your grid, you have to think about it when writing custom logic.

              Comment

              Working...
              X