Announcement

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

    ListGrid unsorted after cell edit?

    Hi Isomorphic,

    I'm observing a quite strange behavior of sorting the ListGrid with editable cells. Since we've upgraded from SGWT4.1 to 5.0, the grid became unsorted after any cell is edited.

    I've found there is a part of code in ListGrid.js, function dataChanged(), which unsorts the grid, at least for the case of editing cells, which are part of the sorting definition. The unsort() function is called.
    But I think the sorting should persist even is this case, or am I wrong?

    This can be easily reproduced in the SGWT showcase. See editable grid example:
    http://www.smartclient.com/smartgwt/showcase/#grid_editing_cell

    Sort the grid by, e.g. Country and then edit any cell in this column. After the value change is applied, the sorting is lost.

    Version: 5.0p
    Built Wed May 27 10:09:00 GMT+200 2015

    Best regards.

    #2
    It's not clear what behavior you're referring to by "unsorting".

    By design, when the user saves edits to the grid, the grid stops enforcing the current sort direction to avoid popping the edited record out of view, which would generally be jarring for the user. This is documented here, and the behavior is much older than 5.0.

    If you think there's some kind of undesirable behavior or bug, you should be more specific about what the behavior is and why you think it's undesirable.

    Comment


      #3
      Thanks for the reply.

      Ok, I must admit that it was too general description of the problem.
      I get the point with unsorting ("...Turn sorting off, typically because data has changed and is no longer sorted..."), when the sort field value is changed.

      Our use case is, that even if some another field value is changed, the unsort is processed.
      Newly I've found out, that this happens only when sorting is applied to the DATE fields.
      There is a method "fieldValuesAreEqual(field, value1, value2)" called on ListGrid during dataChanged(), which in case of Date field, may return False even for the same dates.
      Please see the attached img file with screenshot from debugging console.

      Probable cause is using SortSpecifiers, which are constructed from field name and sort direction only. But the "fieldValuesAreEqual" method checks the "field.type" for correct comparing the Date fields. Unfortunately it is only String (the field name).

      To reproduce this behavior, please try the following code with test DataSource: /examples/shared/ds/test_data/world.data.xml

      Code:
      isc.ListGrid.create({
          ID: "countryList",
          width:500, height:224, alternateRecordStyles:true,
          dataSource: worldDS,
          // display a subset of fields from the datasource
          fields:[
              {name: "independence"}, //Date field
              {name:"countryCode"},
              {name:"countryName"},
              {name:"capital"},
              {name:"continent"}
          ],
          initialSort: [{property: "independence",  direction: "descending"}],
          dataPageSize: 50,
          autoFetchData: true,
          selectionType: "single",
          canEdit: true
      })
      Change any value in column, e.g. Country, the sort arrow will be hidden on edit complete.
      (just note: in our real application case, the following data fetch reloads data with no sorting defined...)
      Now try to sort by Country and change the value in some other column - the sort arrow remains visible.
      Attached Files

      Comment


        #4
        Ok, this should be fixed for builds dated June 11 and later.

        Comment

        Working...
        X