0
export class Example1 implements OnInit {
  prepareGrid() {
    this.gridOptions = {
      enableRowSelection: true,
      enableCheckboxSelector: true,
      checkboxSelector: {
        // you can override the logic for showing (or not) the expand icon
        // for example, display the expand icon only on every 2nd row
        selectableOverride: (row: number, dataContext: any, grid: any) => (dataContext.id % 2 === 1)
      },
      multiSelect: false,
      rowSelectionOptions: {
        // True (Single Selection), False (Multiple Selections)
        selectActiveRow: true,
      },
    };
  }
}

We can use enableCheckboxSelector to show/hide checkbox. But how to enable/disable checkbox based on some condition dynamically ?

1 Answer 1

1

The question is already answered in the Wiki documentations, you can use selectableOverride, refer to Row Selection - Wiki, but it seems that you already have that code, or maybe you didn't understand what that was for?

If you want to change the selected row(s) at any point in time, then simply use the built-in SlickGrid method setSelectedRows(rowIndexes) which requires an array of row indexes, passing an empty array will clear all selections.

<angular-slickgrid 
  gridId="grid4" 
  [columnDefinitions]="columnDefinitions" 
  [gridOptions]="gridOptions"
  [dataset]="dataset" 
  (onAngularGridCreated)="angularGridReady($event)"> <!-- <<== you need this line !-->
</angular-slickgrid>
angularGridReady(angularGrid: AngularGridInstance) {
  this.angularGrid = angularGrid;
}

changeRowSelection() {
  angularGrid.slickGrid.setSelectedRows(rowIndexes);
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.