Bug when using ctrl click in grid combined with getSelectedState()?

1 Answer 57 Views
Data Query Grid
Ricky
Top achievements
Rank 1
Iron
Ricky asked on 12 Apr 2022, 10:22 AM | edited on 12 Apr 2022, 10:23 AM

Hi,

When using the grid, you can single click rows, shift click a range and ctrl click. These all work fine. I'm creating a wrapper around the grid to return the clicked rows, so this is the code I use to do this:

const onSelectionChange = event => { const newSelectedState = getSelectedState({ event, selectedState: selectedState, dataItemKey: DATA_ITEM_KEY, }); const selectedRows = Object.keys(newSelectedState).map(x => data.find(d => d[DATA_ITEM_KEY].toString() === x.toString())); props.onSelected(selectedRows); setSelectedState(newSelectedState); };

So I loop the data keys returned from the getSelectedState method on my data collection. Great, works fine.

However, when shift selecting a range and then deselecting a single row holding control, the row still remains as selected using getSelectedState (visibly it's unclicked, but not the state object). This is not the case with shift. Shift correctly unselects the rows. I see the event returns a ctrlKey property, so I could probably add my own code around this issue - but it looks like a bug to me? I am using the newest versions of the grid and data tools (kendo-data-tools: 5.2.0 and kendo-react-grid: 5.2.0).

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 13 Apr 2022, 07:17 AM

Hello,

I have tested this locally and the selected state is correct. The deselected item is marked as false. Please have in mind that the id of the item will still be part of the object, but with value false:

{1: true, 2: true, 3: false, 4: true, 5: true}

You can update the logic to only get the keys with value true in order to get the selected items.

Regards,
Stefan
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.

Ricky
Top achievements
Rank 1
Iron
commented on 13 Apr 2022, 08:09 AM | edited

I swear I tried that and they all reported true. I since have updated the packages and it does now indeed reflect the selected state. Apologies, should have verified that first. Thanks.
Tags
Data Query Grid
Asked by
Ricky
Top achievements
Rank 1
Iron
Answers by
Stefan
Telerik team
Share this question
or