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

13 posts, 0 answers
  1. StackOverflowed
    StackOverflowed avatar
    32 posts
    Member since:
    Sep 2010

    Posted 29 Mar 2011 Link to this post

    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. 

  2. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 31 Mar 2011 Link to this post

    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
  3. StackOverflowed
    StackOverflowed avatar
    32 posts
    Member since:
    Sep 2010

    Posted 01 Apr 2011 Link to this post

    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?
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 04 Apr 2011 Link to this post

    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
  5. StackOverflowed
    StackOverflowed avatar
    32 posts
    Member since:
    Sep 2010

    Posted 12 Apr 2011 Link to this post

    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.
  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 14 Apr 2011 Link to this post

    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
  7. StackOverflowed
    StackOverflowed avatar
    32 posts
    Member since:
    Sep 2010

    Posted 14 Apr 2011 Link to this post

    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.
  8. Rayne
    Rayne avatar
    261 posts
    Member since:
    Sep 2010

    Posted 21 Sep 2011 Link to this post

    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?
  9. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 22 Sep 2011 Link to this post

    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 >>

  10. Rayne
    Rayne avatar
    261 posts
    Member since:
    Sep 2010

    Posted 22 Sep 2011 Link to this post

    I'm using 2011.2.912.40.
  11. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 26 Sep 2011 Link to this post

    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 >>

  12. Rayne
    Rayne avatar
    261 posts
    Member since:
    Sep 2010

    Posted 26 Sep 2011 Link to this post

    Thanks for the clarification. For some reason, binding to IsReadOnly now works. Maybe it was just being stubborn.
  13. Niki
    Niki avatar
    6 posts
    Member since:
    Apr 2013

    Posted 05 Sep 2013 Link to this post

    Post deleted as I realised I was talking rubbish!
Back to Top