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

RagGridView - Cell Edit Commit issues

6 Answers 177 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 06 Oct 2015, 02:41 PM

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?

 

 

6 Answers, 1 is accepted

Sort by
0
Chris
Top achievements
Rank 1
answered on 07 Oct 2015, 08:59 AM

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

0
Maya
Telerik team
answered on 08 Oct 2015, 07:27 AM
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
0
Chris
Top achievements
Rank 1
answered on 08 Oct 2015, 08:16 AM

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.

 

0
Maya
Telerik team
answered on 08 Oct 2015, 08:41 AM
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
0
Chris
Top achievements
Rank 1
answered on 08 Oct 2015, 09:42 AM

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.

0
Maya
Telerik team
answered on 09 Oct 2015, 06:09 AM
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
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Chris
Top achievements
Rank 1
Maya
Telerik team
Share this question
or