This is a migrated thread and some comments may be shown as answers.

RadGridView allows entry into edit mode for disabled cells by typing characters

12 Answers 456 Views
GridView
This is a migrated thread and some comments may be shown as answers.
StackOverflowed
Top achievements
Rank 1
StackOverflowed asked on 29 Mar 2011, 09:11 PM
The default grid seems to allow you to enter edit mode by typing a character (mouse clicks don't work) when the editor is disabled. Not only is this inconsistent behavior, but converters can end up throwing exceptions because of invalid input. 

12 Answers, 1 is accepted

Sort by
0
Nedyalko Nikolov
Telerik team
answered on 31 Mar 2011, 10:23 PM
Hi StackOverflowed,

There is a property called EditTriggers both on a grid and on a column level. Indeed the default edit triggers are F2, CurrentCellClick and TextInput. You can easily set this property in xaml like this:

<telerik:RadGridView EditTriggers="Default, CellClick" .../>

in order to meet your goals.

Regards,
Nedyalko Nikolov
the Telerik team
0
StackOverflowed
Top achievements
Rank 1
answered on 01 Apr 2011, 02:35 PM
This doesn't solve the problem. I still want TextEntry to be an EditTrigger, but not when the cell is disabled. How does enabling editing when a cell is disabled even make any sense?
0
Maya
Telerik team
answered on 04 Apr 2011, 09:46 AM
Hello David,

May you provide a bit more details about your exact scenario and the settings of the grid? Generally, if a cell is disabled or read-only, it cannot be edited. I am sending you the sample project I used for testing the case. The first column is disabled, while the second one is read-only. However, typing on each of the does not result in editing the cell. 
Let me know in case of any misunderstandings.
 

Greetings,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
StackOverflowed
Top achievements
Rank 1
answered on 12 Apr 2011, 07:41 PM
Using your example, all I have to do is select any cell in the Established column and move one left. Even though the Name cell is disabled, the grid will still navigate to it. Type in a letter and you will see that letter being entered in the cell's TextBox. The grid shouldn't be passing TextInput into a disabled cell.
0
Maya
Telerik team
answered on 14 Apr 2011, 09:53 AM
Hello David,

You are quite correct - the behavior can be indeed reproduced following the steps you described. The issue will be resolved with the upcoming Service Pack. So, once the fix is available, you will still be able to navigate as now, but editing the cell will not be allowed.
Thank you for your cooperation.

All the best,
Maya
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
StackOverflowed
Top achievements
Rank 1
answered on 14 Apr 2011, 03:30 PM
For anyone else experiencing this problem, a current workaround I've found is to listen for the BeginningEdit event, and check in there if the cell is disabled, and if so, set e.Cancel = true.
0
Rayne
Top achievements
Rank 1
answered on 21 Sep 2011, 05:39 PM
I have a property in my viewmodel that always returns true (for test purposes). I'm binding this property to IsReadOnlyBinding on my grid.

My grid row cells are still editable (so long as they have a control other than a textbox for editing). The cells that would have a textbox for editing (even the column defined as readonly in xaml) are throwing up a NullReferenceException when they attempt to enter edit mode.

System.NullReferenceException: Object reference not set to an instance of an object.
   at Telerik.Windows.Controls.GridViewBoundColumnBase.EvaluateIsReadOnlyState(Object item)
   at Telerik.Windows.Controls.GridViewBoundColumnBase.CanEdit(Object item)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.BeginEdit(GridViewCell gridViewCell, RoutedEventArgs editingEventArgs)
   at Telerik.Windows.Controls.GridView.GridViewDataControl.OnCellMouseDown(GridViewCell cell, MouseButtonEventArgs args)
   at Telerik.Windows.Controls.GridView.GridViewCell.OnMouseLeftButtonDown(MouseButtonEventArgs e)
   at System.Windows.UIElement.OnMouseLeftButtonDownThunk(Object sender, MouseButtonEventArgs e)
......

I'm not sure what is going on, but I need to be able to set the grid to readonly based on business rules and it seems that it isn't working.

The only cell that is behaving is a column that I defined in xaml as readonly, but is bound to datetime value (so the default editor wouldn't be a textbox).

Can anyone help with this?
0
Vlad
Telerik team
answered on 22 Sep 2011, 06:31 AM
Hello,

 Can you post more info about your grid version? Is it our Q2 2011 or Q2 2011 SP1?

Regards,
Vlad
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rayne
Top achievements
Rank 1
answered on 22 Sep 2011, 01:23 PM
I'm using 2011.2.912.40.
0
Nedyalko Nikolov
Telerik team
answered on 26 Sep 2011, 10:07 AM
Hi Rayne,

I'll try to clarify IsReadOnlyBinding property a little bit.
The idea behind this property is to determinate of a single row can enter into edit mode. Therefore IsReadOnlyBinding property has underlying business object (which is about to enter in edit mode) as DataContext. For example if you are trying to put cell (row 2 and column 2) in edit mode IsReadOnlyBinding.DataContext will be row2.DataContext, no matter that this property is set on a column or on a grid level. Keeping this in mind in order to achieve your goals IsReadOnlyBinding should be bound to a property of your BO.

For more information about IsReadOnlyBinding property you can take a look at this online help topic.
Let me know if there is something unclear.

Greetings,
Nedyalko Nikolov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Rayne
Top achievements
Rank 1
answered on 26 Sep 2011, 09:50 PM
Thanks for the clarification. For some reason, binding to IsReadOnly now works. Maybe it was just being stubborn.
0
Niki
Top achievements
Rank 1
answered on 05 Sep 2013, 02:36 PM
Post deleted as I realised I was talking rubbish!
Tags
GridView
Asked by
StackOverflowed
Top achievements
Rank 1
Answers by
Nedyalko Nikolov
Telerik team
StackOverflowed
Top achievements
Rank 1
Maya
Telerik team
Rayne
Top achievements
Rank 1
Vlad
Telerik team
Niki
Top achievements
Rank 1
Share this question
or