Igniteui-angular: How to disable selection for few rows based on any condition in multi selection of igx-grid ignite UI for angular?

Created on 19 Dec 2019  路  1Comment  路  Source: IgniteUI/igniteui-angular

general row-selection selection question

Most helpful comment

Hi @ivanovla ,
Thanks for the thorough explanation!

I think your desired behavior can be achieved by templating the header checkbox and attaching a listener to the onRowSelectionChange event emitter:
On the emitter, filter the newSelection, removing all of the disabled IDs from it.
For the header, override the default header with a checkbox that does the following:

  • Handle the click event, stopping it's propagation (so it does not trigger the default header behavior)
  • Call the grid's selection API depending on the state - deselect all rows if totalSelectable - totalSelected === 0 or select all selectable rows (data - disabled)
  • Handles it's view state depending on the selection state (checked state and indeterminate state)

For the rows that are not selectable, hide the selectors by providing a conditional template.

Here is a small StackBlitz sample with the proposed setup - when you have the time, give it a look and let us know if this works for your scenario.

>All comments

Hi @ivanovla ,
Thanks for the thorough explanation!

I think your desired behavior can be achieved by templating the header checkbox and attaching a listener to the onRowSelectionChange event emitter:
On the emitter, filter the newSelection, removing all of the disabled IDs from it.
For the header, override the default header with a checkbox that does the following:

  • Handle the click event, stopping it's propagation (so it does not trigger the default header behavior)
  • Call the grid's selection API depending on the state - deselect all rows if totalSelectable - totalSelected === 0 or select all selectable rows (data - disabled)
  • Handles it's view state depending on the selection state (checked state and indeterminate state)

For the rows that are not selectable, hide the selectors by providing a conditional template.

Here is a small StackBlitz sample with the proposed setup - when you have the time, give it a look and let us know if this works for your scenario.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tkiryu picture tkiryu  路  3Comments

nikunjgajera picture nikunjgajera  路  3Comments

nikunjgajera picture nikunjgajera  路  3Comments

ymita picture ymita  路  3Comments

furugen picture furugen  路  3Comments