Double click and multiselect

1 Answer 163 Views
Grid
Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
Giovanni asked on 16 May 2022, 08:12 AM

Hi, I'm trying to combine many functionality on kendo react data grid.

I want to allow multiselect, custom cell, custom menu filter, contextual menu and double click managing.

I tried like in following project:

https://stackblitz.com/edit/react-tcu25m

 

I started from following examples:

https://stackblitz.com/edit/react-7mz85d (double click managing)

https://stackblitz.com/edit/react-fx9xkl (multiselect)

But, combining the 2 way the double click fires only sometimes. Maybe because the click was consumed by selection?

How can I get all my needs?

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 18 May 2022, 06:49 AM

Hello Giovanni,

Your assumption is correct and the issue is due to the selection functionality, which after the first click changes the selected state, thus forcing the row to be rendered with the new state. This means that when the row is clicked second time (for the double click), the previous element in the DOM will already be gone and only the click event for the new element will fire.

What I could suggest is to enable the selection only through the checkbox, which will allow you to have a double click handler as well:

Please note that I have removed the preventDefault from the onClick in the rowRender, because it interferes with the checkbox selection.

As a side note, for allowing the double click and the click to select, you might consider adding a double click handler for the wrapping element of the Grid (or some other wrapping element that will have the rows as children elements and will not be re-rendered after a single click).

 

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.

Giovanni
Top achievements
Rank 1
Iron
Iron
Iron
commented on 19 May 2022, 03:11 PM | edited

Hi, thanks for your reply.

We're porting our existing app (made with JQuery and Kendo for JQuery) to KendoReact, and unfortunately we'd absolutely need to replicate the same exact behavior in the new one. We'd need to have click for selection, multiselection with the checkboxes and doubleclick support at the same time, for custom and regular cells.

I've noticed it does work perfectly if I have a custom cell without nested DIVs, just

<td> someCustomString </td>

With the above, all selection, multiselection and doubleclick work flawlessly.

 

Sorry but I do not understand what you mean in your side note. Could you please provide an example - editing your previous one or mine, if you like? Would it allow support for all the three features I need at the same time?

Konstantin Dikov
Telerik team
commented on 23 May 2022, 07:50 AM

Hello  Giovanni,

While playing around with the scenario I came up with a different way for handling the re-mounting of the row on selection. Since the row is rendered again on selection, if we wrap the selection logic in a setTimeout function, this will give the double-click time to fire before the row is re-rendered. I have modified the example, so it can handle both events:

The setTimeout is placed within the onSelectionChange event. I have also included logic for removing the timeout if the checkbox is clicked, so that it does not introduce a delay for the checkbox selection.

Hope this helps.

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