Kendo Grid (React) - conditionally disable selectable rows

1 Answer 1487 Views
Grid
Krzysztof
Top achievements
Rank 1
Krzysztof asked on 14 Jun 2022, 08:26 AM | edited on 14 Jun 2022, 08:35 AM

Hello all,

I'm trying to implement a functionality which relies on Kendo Grid (React + Typescript) with selectable rows (with checkbox) as in the second example in the docs:

https://www.telerik.com/kendo-react-ui/components/grid/selection/

Is there any way (based on that example) to make the rows conditionally disabled? Say I click one of the rows which does two things:

  • sets some filtering state (not a problem),
  • based on this state I make it impossible to select another row. They should become disabled, and greyed out (struggling to achieve this)

What I tried to do was removing pointerEvents by setting them to none, but this one unfortunately also removed the tooltip that should be attached to each row explaining why it's been disabled.

I also tried to override Grid's onRowClick event by:

onRowClick={()=>{}}
but this didn't prevent the row from being selectable.

 

Any help much appreciated,

Krzysztof

1 Answer, 1 is accepted

Sort by
1
Accepted
Konstantin Dikov
Telerik team
answered on 16 Jun 2022, 07:13 AM

Hello Krzysztof,

Thank you for reaching out to us.

The select functionality of the Grid is handled manually by changing the select field value in the underlying data item, which mean that if you want to prevent the selection for particular rows, you can achieve this within the logic that updates the selected state.

As for disabling the checkboxes for particular rows conditionally, you can render disabled checkbox within the "cellRender" of the Grid based on some condition within the data item. Following is a simple example demonstrating such implementation:

Note that the same logic for disabling the rows is included in the "select all" logic in the header.

Hope this helps.

 

Regards,
Konstantin Dikov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Krzysztof
Top achievements
Rank 1
commented on 06 Jul 2022, 07:30 AM

Thank you for the answer. Looks like this is what we're looking for.

 

Tags
Grid
Asked by
Krzysztof
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or