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

GridView.Items.CommitEdit() not making changes as expected?

1 Answer 242 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 14 Aug 2017, 01:49 PM

Hello,

I have a radgridview that populates with data from a database.  I also have three empty columns for entering in information.  The problem I am having is that whenever I enter in information into the columns and click out of the cell, the information disappears and the gridview doesn't update accordingly.  I think I have my code set up right, so I'm unsure of what my issue could be.  Here is my code for my xaml:

<Window         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"         xmlns:local="clr-namespace:DeductionInfoBSAP"         xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" x:Class="DeductionInfoBSAP.MainWindow"         mc:Ignorable="d"         Title="MainWindow" Height="482" Width="764.5"         Loaded="Window_Loaded">        <Window.Resources>        <ResourceDictionary>            <ResourceDictionary.MergedDictionaries>                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/System.Windows.xaml"/>                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.xaml"/>                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.Input.xaml"/>                <ResourceDictionary Source="/Telerik.Windows.Themes.Office2016;component/Themes/Telerik.Windows.Controls.GridView.xaml"/>            </ResourceDictionary.MergedDictionaries>        </ResourceDictionary>    </Window.Resources>        <Grid>            <Grid.Resources>                <local:ViewModel x:Key="ViewModel"/>            </Grid.Resources>        <telerik:RadGridView x:Name="gridView" Margin="0,0,0,-454" ScrollViewer.HorizontalScrollBarVisibility="Visible" IsReadOnly="False" AlternationCount="-1" IsManipulationEnabled="True" SelectionChanged="gridView_SelectionChanged" CellEditEnded="gridView_CellEditEnded" CurrentCellChanged="gridView_CurrentCellChanged" />    </Grid></Window>

 

Here is my code for the gridView_CellEditEnded event which attempts to commit any edits made to those cells:

bool handle = true;

private void gridView_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)         

{             

if(e.EditAction == GridViewEditAction.Commit && handle)             

{                 

handle = false;                 

gridView.Items.EditItem(this.gridView.CurrentItem);                 

gridView.Items.CommitEdit();                

 handle = true;             

}         

}

If anyone is able to help me understand what I'm doing wrong, it would be greatly appreciated.  I've read every forum and thread I could on this and could not fix my issue.

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 17 Aug 2017, 11:30 AM
Hi Jason,

Thank you for your interest in RadGridView control.

I wasn't able to reproduce the behavior described in your post. Attached to this reply you can find the project which I used to test your scenario. The project is based on the provided code snippet. Can you take a look it and let me know if I am missing something from your implementation in order to reproduce it on my side.

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Jason
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or