Announcement

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

    Can't drag and drop rows in grouped ListGrid and maintain reorder

    Hi,

    I am unable to drag and drop rows within a grouped listgrid. After dropping them, they don't become reordered. They just keep the same order the rows were originally. I have attached a code sample that shows the problem. Can you please look into this? Thanks.

    edit: To clarify, I have setCanReorderRecords(true). Using the drag and drop to reorder works when the grid is not grouped, but when the grouping is enabled, I'm encountering this problem.

    We are using SmartClient Version: v11.1p_2018-04-03/PowerEdition Deployment (built 2018-04-03)
    Attached Files
    Last edited by user316; 4 Jun 2018, 09:47.

    #2
    When grouping without a sort, the order of the rows is based on the order they are encountered in the dataset. You could reorder the rows in the original data and manually call regroup() to cause the new order to be reflected.

    A clearer and more reliable approach would be to have a sort based on a (possibly hidden) field that gives the order. This approach is shown in the sample below.

    https://www.smartclient.com/smartgwt...rable_ListGrid

    This sample shows actual DataSource persistence of the user-specified reorder, although that's not necessary to just maintain order while grouped so long as order need not be maintained on a page reload.

    Comment


      #3
      Originally posted by Isomorphic View Post
      When grouping without a sort, the order of the rows is based on the order they are encountered in the dataset. You could reorder the rows in the original data and manually call regroup() to cause the new order to be reflected.
      I understand what you're saying, but I specifically want to reorder them with drag and drop. In the DropCompleteHandler, it doesn't tell me which row number the record was dropped onto, so I can't do it manually after a drag and drop action.


      A clearer and more reliable approach would be to have a sort based on a (possibly hidden) field that gives the order. This approach is shown in the sample below.

      https://www.smartclient.com/smartgwt...rable_ListGrid

      This sample shows actual DataSource persistence of the user-specified reorder, although that's not necessary to just maintain order while grouped so long as order need not be maintained on a page reload.
      Your example has ungrouped data. Are you saying this above example will work with drag and drop if grouping is applied?

      In my example from my attachment, I tried sorting the data on both a hidden and unhidden field, but I still cannot reorder with drag and drop.

      See screenshot. I have sorting enabled now, but I still can't drag and drop to reorder.


      Click image for larger version

Name:	drag_and_drop_attempt.png
Views:	144
Size:	14.0 KB
ID:	253500
      Last edited by user316; 4 Jun 2018, 10:41.

      Comment


        #4
        The drop location is always available regardless of what handler you are in (listGrid.getDropIndex()).

        If you are grouping on continent, as shown in your screenshot, then of course you are not using a hidden field to maintain an explicit user-specified order, so no, that's not going to work since it isn't the approach we indicated.

        As far as just turning on grouping in the sample of persistent reorder, you will need to write logic so that the index of the dropped record is updated appropriately according to where it is dropped in the group. This is not shown in the sample.

        Comment

        Working...
        X