FlexGrid select all (Ctrl+A) includes empty new row (allowAddNew)

Posted by: steidle on 31 August 2020, 1:35 am EST

    • Post Options:
    • Link

    Posted 31 August 2020, 1:35 am EST - Updated 3 October 2022, 3:41 pm EST

    I have a FlexGrid with allowAddNew=true so there is an extra blank row for new items. When I click on “TopLeft” or hit Ctrl+A or Ctrl+space all rows are selected INCLUDING the blank row for new items.

    So even if there are let’s say 3 rows in a FlexGrid grid.selectedRows contains 4 rows, one without a dataItem. But if I select all rows he would expect this to be equal to the existing rows.

    Is there a smart way to always exclude the “new row” from the “select all” commands?

    The 6 in the picture is grid.selectedRows.length.

  • Posted 1 September 2020, 12:56 am EST

    Hi Andreas,

    Selecting all the rows is expected behavior because an empty row is also considered a row in FlexGrid. You can change this behavior by overriding the selectAll method of FlexGrid and also adding an event listener for Ctrl + Space to only select the data rows.

    Please refer to the sample link below for reference:

    https://stackblitz.com/edit/angular-mvpzbu

    Regards,

    Ashwin

  • Posted 1 September 2020, 4:35 pm EST

    Thanks for the sample. Works like a charm!

Need extra support?

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

Learn More

Forum Channels