ng-matero / extensions

Angular Material Extensions Library.
https://ng-matero.github.io/extensions/
MIT License
393 stars 48 forks source link

mtx-grid: keep rows checkbox selection in case of pagination data from remote #226

Closed SYS64738 closed 10 months ago

SYS64738 commented 11 months ago

Hi, there's a way to preserve rows checkbox selection when data comes from remote (http) after page navigation ? I cannot find a way to check programmatically a row.

Thank you for your support.

nzbin commented 11 months ago

There are two ways to achieve

  1. use the rowSelected prop

    <mtx-grid [rowSelected]="rowSelected"></mtx-grid>
    rowSelected = EXAMPLE_DATA.slice(2, 3);
  2. use the CDK SelectionModel

https://github.com/ng-matero/extensions/blob/63ae586d759d2c6014421d444dc64de34a01007e/projects/extensions/grid/grid.ts#L175

@ViewChild('grid') grid: MtxGrid;
this.grid.rowSelection.select(...);
this.grid.rowSelection.deselect(...);
this.grid.rowSelection.clear();
this.grid.rowSelection.toggle(...);