Flexgrid Row Select not retaining selected rows

Posted by: jason.brandt on 1 November 2018, 6:25 pm EST

    • Post Options:
    • Link

    Posted 1 November 2018, 6:25 pm EST

    When I select rows via the left column checkboxes, there are two problems.

    First, the checks all go away if a data cell is clicked (it de-selects all rows except that one)

    Second, when I page from page 1 to page 2, all checks are lost (and so selected rows are lost)

    How is this fixed?

    https://stackblitz.com/edit/angular-wyp3yb?file=app%2Fdata-svc.service.ts

  • Posted 2 November 2018, 3:30 am EST

    First, the checks all go away if a data cell is clicked (it de-selects all rows except that one)

    <<<<<<<<<<<<<<

    The observed behaviour is by design, when we select selectionMode to ListBox grid auto updates the selectedRows on selectionChanged.

    To stop grid from auto-updating selectedRows, we need to change selectionMode to some other.

    Second, when I page from page 1 to page 2, all checks are lost (and so selected rows are lost)

    <<<<<<<<<<<<<<

    Since changing pages, rebinds rows to data, selections are lost. To preserve the selectedRows during paging you may opt one of the following two ways:

    1). Modify sourceData to have the additional property of ‘isSelectedRow’ and sync that property with the grid rows isSelectedRow property.

    2). Preserve and restore selectedRows during paging

    Please refer to the following sample which demonstrates both the methods:

    https://stackblitz.com/edit/angular-ezelx3?file=app%2Fapp.component.ts

    Regards

    Sharad

  • Posted 5 November 2018, 2:25 pm EST

    Thank you for that great answer.

    After I changed the fetchSelected method to use the sourceCollection, it all worked great.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels