RagGridView - Cell Edit Commit issues

7 posts, 0 answers
  1. Chris
    Chris avatar
    7 posts
    Member since:
    Jul 2015

    Posted 06 Oct 2015 Link to this post

    Hi there,

    I have 2 RadGridViews in a sample project defined as per the attached screenshot (GridViewFocusIssue.png).

    The crux of the issue is as follows:

    -If I edit any of the cells in the 1st grid, and then click on either the TextBox or the Button, then the Cell Edit is committed as expected.

    -If I edit any of the cells in the 1st grid, and then click into a cell in the 2nd grid, the cell that was being edited in the 1st grid doesn't leave Edit mode. (please see ProblemScreenshot.png)

    My desired behaviour is that as soon as a user clicks outside of a cell that is in edit mode, then that cell should have its edit committed.

    Please can you advise how to do this?

     

     

  2. Chris
    Chris avatar
    7 posts
    Member since:
    Jul 2015

    Posted 07 Oct 2015 Link to this post

    I should add that I am on the 2012.3 version of the libraries.

    As an experiment, I have I tried the 2015 trial and the behaviour is as I expect, so I assume this was a bug that was fixed.

    Upgrading is currently not an option for us, so please can you suggest a workaround?

    Thanks

  3. UI for WPF is Visual Studio 2017 Ready
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 08 Oct 2015 Link to this post

    Hello Chris,

    Can you try calling CommitEdit() method of the first grid once the focus is no the other ? Does this resolve the issue ? 


    Regards,
    Maya
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  5. Chris
    Chris avatar
    7 posts
    Member since:
    Jul 2015

    Posted 08 Oct 2015 Link to this post

    Hi Maya,

    I suppose I could and yes it does solve the issue, however it would require every RadGridView in my application to know about every other RadGridView, which is not feasible.

     

  6. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 08 Oct 2015 Link to this post

    Hello Chris,

    You can try adding handlers for LostFocus and GotFocus events and implement the logic once they are fired. It might be something as follows:
    RadGridView gridView;
            public MainWindow()
            {
                InitializeComponent();
                this.AddHandler(RadGridView.GotFocusEvent, new RoutedEventHandler(OnGotFocus), true);
                this.AddHandler(RadGridView.LostFocusEvent, new RoutedEventHandler(OnLostFocus), true);
            }
     
            private void OnGotFocus(object sender, RoutedEventArgs e)
            {
                var focusedElement = e.OriginalSource as FrameworkElement;
                var parentGrid = focusedElement.ParentOfType<RadGridView>();
                if (this.gridView != null && parentGrid != null && !this.gridView.Equals(parentGrid))
                {
                    this.gridView.CommitEdit();
                    this.gridView = null;
                }
            }
     
            private void OnLostFocus(object sender, RoutedEventArgs e)
            {
                var element = e.OriginalSource as FrameworkElement;
                if (element != null)
                {
                    var parentGrid = element.ParentOfType<RadGridView>();
                    this.gridView = parentGrid != null ? parentGrid : null;
                }
            }


    Regards,
    Maya
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  7. Chris
    Chris avatar
    7 posts
    Member since:
    Jul 2015

    Posted 08 Oct 2015 in reply to Maya Link to this post

    May you explain your logic?

    I don't think it can work as the OriginalSource in the OnLostFocus event is always going to be the same local grid.

  8. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 09 Oct 2015 Link to this post

    Hi Chris,

    My idea was to save which instance of RadGridView is the one that loses the focus and if another one gets it, to commit the changes of the first one. 
    Please give it a try and let me know how it goes. 

    Regards,
    Maya
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WPF is Visual Studio 2017 Ready