I am trying to implement the new ColumnGroups introduced in the latest version (2011 Q3) but I am having issues when trying to create the ColumnGroups by code.
The problem occurs when trying to construct ColumnGroups with the below code. (taken from a simple sample to isolate the issue)
this.grid.Columns.Clear();
this.grid.ColumnGroups.Clear();
var gridColumn = new GridViewDataColumn();
var gridColumn2 = new GridViewDataColumn();
if (this.IncludeGroup.IsChecked != null && (bool)this.IncludeGroup.IsChecked)
{
this.grid.ColumnGroups.Add(new GridViewColumnGroup
{
Name = "A",
Header = "A"
});
this.grid.ColumnGroups.Add(new GridViewColumnGroup
{
Name = "B",
Header = "B"
});
gridColumn.ColumnGroupName = "A";
gridColumn2.ColumnGroupName = "B";
}
gridColumn.UniqueName = "a";
gridColumn.Header = "Name";
var textBinding = new Binding("Name");
textBinding.Mode = BindingMode.OneWay;
gridColumn.DataMemberBinding = textBinding;
this.grid.Columns.Add(gridColumn);
gridColumn2.UniqueName = "b";
gridColumn2.Header = "Name";
var textBinding2 = new Binding("Year");
textBinding2.Mode = BindingMode.OneWay;
gridColumn2.DataMemberBinding = textBinding2;
this.grid.Columns.Add(gridColumn2);Any help would be much appreciated,
Rich
13 Answers, 1 is accepted
I have tried to reproduce the issue you reported, but without any success. Could you take a look at the sample attached and let me know whether you can get the same behavior on it ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I can confirm that the attached code works, however, this requires knowledge of the columns to be defined in XAML upfront, unfortuently, we do not have this and the columns must be built at runtime.
It you comment out the ColumnGroup and Column definitions in XAML and run the program, you will receive the same issue that I am having. On clicking the button, the grid will be built but the ColumnGroups will not be shown.
I cannot see what would be causing this as the Button_Click code clears the Columns and ColumnGroups collections and so the grid should be in the same state as startup.
Thanks,
Rich
Indeed, I have managed to reproduce the issue you reported. It has already been resolved and the fix will be available within two weeks with our Service Pack release and probably with next internal build.
I do hope this will not a huge drawback for you and the time frame for the fix is acceptable.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Thanks,
Rich
I have just got the latest release (26th Nov 2011) and have not been able to implement the desired functionality. Using your provided project from above with the latest libraries and commenting out the ColumnGroups and Column definitions in XAML (as I described above) I now get a NullReferenceException on line 33 - MainWIndow.xaml.cs (this.clubsGrid.ColumnGroups.Clear();).
On avoiding Clear() when ColumnGroups.Count == 0 I then receive the NullReferenceException on adding a new GridViewColumnGroup object to the ColumnGroups collection.
Do you have a working example with the latest libraries?
Thanks,
Rich
I have just tested this scenario with the latest LIB ( from Wednesday) . I believe all the issues are solved.
Plese download the LIB and give it a try . In case you need additional assistance or still experience any issues
drop me a line.
All the best,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I just tested the latest internal build and it works as expected, thank you for fixing this.
When will the fix be released?
Thanks,
Rich
The next official release is planned for February (Q1 2012) .
Kind regards,
Pavel Pavlov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Rich
I'm using version 2012.2.912.45, and I'm seeing the same issue.
I can create the column groups in XAML, but they don't work programmatically.
list. Select(f => new { f.HeaderGroup, f.LocationID }). Distinct(). ToList(). ForEach(f => grid.ColumnGroups.Add(new Telerik.Windows.Controls.GridViewColumnGroup() { Header = f.HeaderGroup , Name = string.Format("Location{0}", f.LocationID) })); list. ForEach(f => { grid.Columns.Add(new Telerik.Windows.Controls.GridViewColumn() { Header = f.Header , ColumnGroupName = string.Format("Location{0}", f.LocationID) }); }); // No groups show above any of the newly generated columns BUT... none of my newly created columns (programmatically created) will set themselves to any columngroup.
Lastly, If I create a columngroup in XAML, it will show up if assigned to a XAML column. If I assign one of the new columns to that group, it does not work.
Please advise. I'm thinking about switching tools. This is a corporate contract, and I'm working under their Telerik license.
Thanks,
Chad Lehman
Indeed, this behavior is observed in the version you are working with. However, it has already been resolved. Please download our current official version and work with it instead.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
We've recently upgraded our license and gotten the latest WPF build. Unfortunately, the problem persists.
v2013.1.220.45
Programmatically created columns still cannot have their column groups set.
Chad
I am attaching the sample with the new binaries that I used for reproducing the issue. Could you take a look at it and let me know whether I am missing something ?
Kind regards,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.