This question is locked. New answers and comments are not allowed.
Hi there,
I am using GroupDescriptors for gruoping the rows in grid. I am facing a problem when removing the columns runtime from the grid. Here is steps what I do.
1. Load the grid with some data on constructor itself.
2. On click of "Refresh" button,
a. Remove the columns.
b. Add the same columns (loaded on first load) again.
c. Change the ItemsSource.
d. Clear the group-desciptor and
e. Add the same group-desciptor again.
If the above steps are follow, the aggregated function(s) is not working as expect. It shows the Count value (in this case) first time but it doesn't show any value if Refresh is clicked.
Can anyone please look at the problem and provide the solution? Here is the code snippet.
Regards,
Maulik
I am using GroupDescriptors for gruoping the rows in grid. I am facing a problem when removing the columns runtime from the grid. Here is steps what I do.
1. Load the grid with some data on constructor itself.
2. On click of "Refresh" button,
a. Remove the columns.
b. Add the same columns (loaded on first load) again.
c. Change the ItemsSource.
d. Clear the group-desciptor and
e. Add the same group-desciptor again.
If the above steps are follow, the aggregated function(s) is not working as expect. It shows the Count value (in this case) first time but it doesn't show any value if Refresh is clicked.
Can anyone please look at the problem and provide the solution? Here is the code snippet.
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using System.Windows.Data; using Telerik.Windows.Data; using Telerik.Windows.Controls; namespace SumFunction_RunTime { public partial class MainPage : UserControl { public MainPage() { InitializeComponent(); //Get random data gridView.ItemsSource = Club.GetClubs(01); var newColumn = new CustomGridColumn() { DataMemberBinding = new Binding("StadiumCapacity"), UniqueName = "Capacity_RunTime", Header = "Capacity column created runtime" }; CountFunction sumFunc = new CountFunction() { Caption = "Count" }; newColumn.AggregateFunctions.Add(sumFunc); gridView.Columns.Add(newColumn); //Add Count Aggregated Function this.gridView.GroupDescriptors.Clear(); Telerik.Windows.Data.GroupDescriptor oGD = new Telerik.Windows.Data.GroupDescriptor(); oGD.Member = "Name"; this.gridView.GroupDescriptors.Add(oGD); } private int clickNumber = 0; private void btnRefresh_Click(object sender, RoutedEventArgs e) { gridView.Columns.Clear(); GridViewDataColumn column = new GridViewDataColumn(); column.DataMemberBinding = new Binding("Name"); column.Header = "Name"; gridView.Columns.Add(column); column = new GridViewDataColumn(); column.DataMemberBinding = new Binding("Established"); column.Header = "Established"; gridView.Columns.Add(column); column = new GridViewDataColumn(); column.DataMemberBinding = new Binding("StadiumCapacity"); column.Header = "StadiumCapacity"; gridView.Columns.Add(column); //Get Random Data gridView.ItemsSource = Club.GetClubs(clickNumber); clickNumber ++; if (clickNumber >= 4) clickNumber = 0; //bool desciptorFound = false; //foreach (GroupDescriptor itemGD in this.gridView.GroupDescriptors) //{ // if (itemGD.Member == "Name") // desciptorFound = true; //} this.gridView.GroupDescriptors.Clear(); Telerik.Windows.Data.GroupDescriptor oGD = new Telerik.Windows.Data.GroupDescriptor(); oGD.Member = "Name"; this.gridView.GroupDescriptors.Add(oGD); } } } Regards,
Maulik