RadGridView: make column or cell not clickable

1 Answer 23 Views
GridView
Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
Eldoir asked on 21 Dec 2021, 09:24 AM | edited on 21 Dec 2021, 09:24 AM

Hello,

The leftmost column of my RadGridView has cells containing a "Save" button (a disk icon you can click).

I want users to be able to click on that Save button but not on the cell itself, nor the column, because it's kinda pointless.

I tried setting IsReadOnly to true and IsEnabled to false on this GridViewColumn but it doesn't help!

Thanks for your answer!

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 22 Dec 2021, 09:30 AM

Hello Arthur,

I am not sure what do you mean by saying that the user should not be able to click on the cell itself, but by guess here is that you need to disable the selection and current cell change that happens on cell click. Please correct me if I am wrong. Otherwise, you can achieve your requirement by using the PreviewMouseLeftButtonDown event of RadGridView where you can handle the click action in case a cell from the button's column is clicked.

You can find this approach shown in the attached project. I hope that helps.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 22 Dec 2021, 09:42 AM

Hello Martin,

This is what I was looking for. Thanks!

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 22 Dec 2021, 02:42 PM

EDIT: actually I answered too fast.

The event is not triggered if I click on a cell, only if I click on the background of the grid (where there are no rows).
I can't get it to work when I click on a cell!

Martin Ivanov
Telerik team
commented on 24 Dec 2021, 10:00 AM

I've double checked my project and I can confirm that the event is triggered wherever you click. Can you please test it with the latest version of UI for WPF and see if the project works as expected? Also, can you record a video showing where exactly do you click in order for the event to be skipped? And one more thing, which Telerik theme do you use?

In the meantime, you can try to use the AddHandler() method in order to subscribe to the event. This will allow you to allow handled events too.

this.gridView.AddHandler(RadGridView.PreviewMouseLeftButtonDownEvent, new MouseButtonEventHandler(RadGridView_PreviewMouseLeftButtonDown), true);

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 03 Jan 2022, 03:51 PM

Hello Martin,

First, happy new year :o)

I don't remember what I did exactly 2 weeks ago that made it not work, but after restarting from scratch, the event seems to be triggered now.

Still, it's a lot of code for a simple "NotSelectable" feature that would be much more convenient to handle per column.
Does it sound relevant to you? Is it something planned for a future update?

Anyway, I believe that users of Telerik would expect the column cells not to be selectable when the column is flagged with "IsEnabled = false"!

Martin Ivanov
Telerik team
commented on 06 Jan 2022, 11:59 AM

Happy New Year!

I am glad to hear that you managed to run the solution on your side.

About the "NotSelectable" feature, can you tell me how the cell click should behave exactly in case the cell is not selectable? Note that there are two things that happen when you click onto a cell. The cell or the entire row get selected (based on the SelectionUnit) and also the clicked cell becomes current cell. In other words, there are two features - selection and currency - that appear on cell click.

Can you tell me which one do you want to disable with the "NotSelectable" feature? Or maybe you want to disable both the selection and the currency setting?

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 06 Jan 2022, 02:00 PM

Yes, I would want to disable both I guess. This wouldn't prevent the user from clicking a button within a cell, right?
Martin Ivanov
Telerik team
commented on 07 Jan 2022, 12:06 PM

Thank you for the feedback. Based on it I've opened a new feature request in the Telerik UI for WPF Feedback Portal. There you can track its status. You can also find your Telerik points updated.

In the details of the feature I've described that the feature should disable only the selection and currency changes. Anything custom inside the cell (like a button) will be available for interaction.

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 07 Jan 2022, 03:02 PM

Thanks Martin!
Tags
GridView
Asked by
Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or