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

Editing grouped data => inconsistent row-order

7 Answers 175 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steffen
Top achievements
Rank 1
Veteran
Steffen asked on 13 Apr 2010, 09:53 AM
Hi,

when editing grouped data the row-order changes when the gridview is not sorted at all or the sort-values are not distinct.
After editing a value the just edited row jumps to the last position of the group. Maybe it has something to do with the RowState (the gridview is bound to a strongly typed DataSet). Also the aggregates are not updating when the data changes.
Also after programmatically grouping a few times the GridViewDataColumn's SourceUpdated-events are not getting raised anymore? Is grouped-data supposed to be read-only?
Am I missing something?



Any ideas?

Best Regards
Steffen

7 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 16 Apr 2010, 12:00 PM
Hello Steffen,

I have created sample application using data set. However I am unable to reproduce the problems - Row reorders on edit and aggregates updates. Can you please check it and let me know if this help you. If not can you please end some additional information about the code and the steps in which the problem occurs.

About the SourceUpdated event - what is the scenario in which it is used? I believe that we can suggest better alternative.

Sincerely yours,
Tsvyatko
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
Steffen
Top achievements
Rank 1
Veteran
answered on 21 Apr 2010, 04:28 PM
Hi,
thanks for the sample. While trying to reproduce the behaviour with your sample I somehow managed to break grouping completely (per drag'n'drop => programmatically seems to work). What am I doing wrong?

Here it is:

I took out the white-space in "Picture Name" ==>  "Picture_Name" in the DataSetDesigner.
I bound to DataTable.DefaultView and used CellTemplates instead of DataMemberBinding.

code behind:
public partial class Window1 : Window 
    { 
        NorthwindDataSet ds = new NorthwindDataSet(); 
        public Window1() 
        { 
            InitializeComponent(); 
 
            NorthwindDataSetTableAdapters.CarsTableAdapter ad = new WPF.GrouedEdit.NorthwindDataSetTableAdapters.CarsTableAdapter(); 
 
            ad.Fill(ds.Cars); 
 
            ds.Cars.ColumnChanged += new System.Data.DataColumnChangeEventHandler(Cars_ColumnChanged); 
 
            SampleGrid.DataContext = ds.Cars.DefaultView; 
            SampleGrid.AutoGeneratingColumn += new EventHandler<Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs>(SampleGrid_AutoGeneratingColumn); 
        } 
 
 
        void SampleGrid_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e) 
        { 
            e.Column.SourceUpdated += new EventHandler<DataTransferEventArgs>(Column_SourceUpdated); 
        } 
 
        void Column_SourceUpdated(object sender, DataTransferEventArgs e) 
        { 
            MessageBox.Show("Source updated"); 
        } 
 
        private void Button_Click(object sender, RoutedEventArgs e) 
        { 
            SampleGrid.GroupDescriptors.Add( 
                new GroupDescriptor() 
                { 
                    Member = "Id"
                    MemberType = typeof(int
                }); 
        } 
 
        private void SampleGrid_Loaded(object sender, RoutedEventArgs e) 
        { 
            //Button_Click(null, null); 
        } 
 
        static int counter = 0; 
        private void CheckBox_SourceUpdated(object sender, DataTransferEventArgs e) 
        { 
            NorthwindDataSet.CarsRow car = ((sender as CheckBox).DataContext as DataRowView).Row as NorthwindDataSet.CarsRow; 
 
            car.BeginEdit(); 
            car.Picture_Name = "modified " + (counter++).ToString(); 
            car.EndEdit(); 
 
 
            //MessageBox.Show("CheckBox_SourceUpdated"); 
        } 
 
        void Cars_ColumnChanged(object sender, System.Data.DataColumnChangeEventArgs e) 
        { 
            //if (e.Column.ColumnName == "BMP") 
            //{ 
            //    e.Row["Picture_Name"] = "modified " + (counter++).ToString(); 
            //} 
        }      
 
 
        private void GridViewDataColumn_SourceUpdated(object sender, DataTransferEventArgs e) 
        { 
            //NorthwindDataSet.CarsRow car = (sender as GridViewDataColumn).DataContext as NorthwindDataSet.CarsRow; 
 
            //does not work: 
            //car.BeginEdit(); 
            //car.Picture_Name = "modified " + (counter++).ToString(); 
            //car.EndEdit(); 
        } 
 
        private void btn_changeNames_Click(object sender, RoutedEventArgs e) 
        { 
            foreach (var item in ds.Cars) 
            { 
                item.Picture_Name = "modified " + (counter++).ToString(); 
            } 
        } 
    } 

XAML:
<Window x:Class="WPF.GrouedEdit.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
        xmlns:sys="clr-namespace:System;assembly=mscorlib" 
    Title="Window1" Height="300" Width="300"
    <Grid> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="20"></RowDefinition> 
            <RowDefinition></RowDefinition
        </Grid.RowDefinitions> 
         
        <Grid> 
            <Grid.ColumnDefinitions> 
                <ColumnDefinition/> 
                <ColumnDefinition/> 
            </Grid.ColumnDefinitions> 
             
            <Button Content="Group by Name" Click="Button_Click"></Button> 
            <Button Grid.Column="1" Content="Change Names" Name="btn_changeNames" Click="btn_changeNames_Click"></Button> 
        </Grid> 
         
        <telerik:RadGridView Grid.Row="1" x:Name="SampleGrid" AutoGenerateColumns="False" ShowInsertRow="True" CanUserInsertRows="True" Loaded="SampleGrid_Loaded" ItemsSource="{Binding}"
            <telerik:RadGridView.Columns> 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding KBytes}" Header="KBytes"
                    <telerik:GridViewDataColumn.AggregateFunctions> 
                        <!--<telerik:FirstFunction Caption="First: "  /> 
                        <telerik:CountFunction Caption="Count: "  />--> 
                        <telerik:SumFunction SourceField="KBytes" SourceFieldType="{x:Type sys:Decimal}"></telerik:SumFunction> 
                    </telerik:GridViewDataColumn.AggregateFunctions> 
                </telerik:GridViewDataColumn> 
                <!--<telerik:GridViewDataColumn DataMemberBinding="{Binding Date}"/> 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Picture Name}"/> 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding BMP}"/>--> 
 
                <!--<telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Date}"/> 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=Picture_Name}"/> 
                <telerik:GridViewDataColumn DataMemberBinding="{Binding Path=BMP}"/>--> 
 
                <telerik:GridViewDataColumn Header="Date" GroupMemberPath="Date" SortMemberPath="Date"
                    <telerik:GridViewColumn.CellTemplate> 
                        <DataTemplate> 
                            <telerik:RadDatePicker Width="160" SelectedDate="{Binding Path=Date}"/> 
                        </DataTemplate> 
                    </telerik:GridViewColumn.CellTemplate> 
                </telerik:GridViewDataColumn> 
                 
                <telerik:GridViewDataColumn Header="Picture_Name" GroupMemberPath="Picture_Name" SortMemberPath="Picture_Name"
                    <telerik:GridViewColumn.CellTemplate> 
                        <DataTemplate> 
                            <TextBox Width="100" Text="{Binding Path=Picture_Name, Mode=TwoWay}"/> 
                        </DataTemplate> 
                    </telerik:GridViewColumn.CellTemplate> 
                </telerik:GridViewDataColumn> 
 
                <telerik:GridViewDataColumn Header="BMP" GroupMemberPath="BMP" SortMemberPath="BMP" SourceUpdated="GridViewDataColumn_SourceUpdated"
                    <telerik:GridViewColumn.CellTemplate> 
                        <DataTemplate> 
                            <CheckBox Width="60" IsChecked="{Binding Path=BMP, NotifyOnSourceUpdated=True}" SourceUpdated="CheckBox_SourceUpdated"/> 
                        </DataTemplate> 
                    </telerik:GridViewColumn.CellTemplate> 
                </telerik:GridViewDataColumn> 
 
            </telerik:RadGridView.Columns> 
 
 
        </telerik:RadGridView> 
    </Grid> 
</Window> 
 

Best Regards
Steffen
0
Tsvyatko
Telerik team
answered on 22 Apr 2010, 01:02 PM
Hi Steffen,

The problem you have encountered is most likely related to current item synchronization -  (if the exception thrown is InvalidOperationException). It was a known problem and has been resolved. It will be available in our Service Pack.

If you have any others questions or features do not hesitate to contact us.

Sincerely yours,
Tsvyatko
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
Anton
Top achievements
Rank 2
answered on 21 Aug 2012, 04:22 PM
I have the same problem. Did you find solution?
Telerik.Windows.Controls.GridView.dll version is "2011.3.1220.40".
0
Steffen
Top achievements
Rank 1
Veteran
answered on 27 Aug 2012, 12:50 PM
Hi,

I'm sorry to tell you that I have no idea how I fixed this because it's been such a long time. I'm still on version 2011.1.704.40.

A few tips for groups/aggregates:
- set DataType on all Columns
- always try to manually refresh the aggregates (there's a GridView-Mehtod for that) when anything changes. Even if they update 10 times in a row - sometimes they just won't update.
- if it seems to work try it with empty data
- plain CLR-objects seem to have less issues than the ADO.NET stuff -> try if a wrapper solves your problem.

Best Regards
Steffen
0
Waut
Top achievements
Rank 1
answered on 25 Apr 2013, 07:03 AM
Hello all

sorry for replying on an old post, but I still have the same problem and i have version 2012.3.1203.40. I use a gridview with 2 columns. Both are GridViewDatacolumns. The second column has variable datatypes and uses a CellEditTemplateSelector to edit those variable datatypes. The data itselve is grouped. And everytime it has done editing, the edit row ends up on the bottom of the group.

Can someone please help me?

EDIT: I found a solution by adding an ordernummer to the data and order on that number lik this
ListCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("GroupID"));
ListCollectionView.GroupDescriptions.Add(new PropertyGroupDescription("SubGroupID", new GroupStringConverter()));
ListCollectionView.SortDescriptions.Add(new SortDescription("GroupID", ListSortDirection.Ascending));
ListCollectionView.SortDescriptions.Add(new SortDescription("SubGroupID", ListSortDirection.Ascending));
ListCollectionView.SortDescriptions.Add(new SortDescription("SubID", ListSortDirection.Ascending));


Waut
0
Dimitrina
Telerik team
answered on 30 Apr 2013, 07:22 AM
Hello Waut,

Thank you for the update.

Generally if you have defined SortDescriptors as well as GroupDescriptors, then after you edit a value and commit the edit, the value will be sorted based on the sorting criteria. 

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Steffen
Top achievements
Rank 1
Veteran
Answers by
Tsvyatko
Telerik team
Steffen
Top achievements
Rank 1
Veteran
Anton
Top achievements
Rank 2
Waut
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or