ColumnGroups do not display when set by code

14 posts, 1 answers
  1. Rich
    Rich avatar
    6 posts
    Member since:
    Jul 2012

    Posted 01 Dec 2011 Link to this post

    Hi,

    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);
    It will refresh the whole GridView correctly except for the ColumnGroups.

    Any help would be much appreciated,
    Rich
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 02 Dec 2011 Link to this post

    Hi Rich,

    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 ? 

     

    Regards,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Rich
    Rich avatar
    6 posts
    Member since:
    Jul 2012

    Posted 06 Dec 2011 Link to this post

    Hi,

    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
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 08 Dec 2011 Link to this post

    Hello 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.
     

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  5. Rich
    Rich avatar
    6 posts
    Member since:
    Jul 2012

    Posted 08 Dec 2011 Link to this post

    That time frame is good for us.

    Thanks,
    Rich
  6. Rich
    Rich avatar
    6 posts
    Member since:
    Jul 2012

    Posted 03 Jan 2012 Link to this post

    Hi,

    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
  7. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 06 Jan 2012 Link to this post

    Hi Richard ,

    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 >>

  8. Rich
    Rich avatar
    6 posts
    Member since:
    Jul 2012

    Posted 06 Jan 2012 Link to this post

    Hi,

    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
  9. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 06 Jan 2012 Link to this post

    Hello Richard,

    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 >>

  10. Rich
    Rich avatar
    6 posts
    Member since:
    Jul 2012

    Posted 06 Jan 2012 Link to this post

    Thank you.

    Rich
  11. Chad
    Chad avatar
    5 posts
    Member since:
    Feb 2013

    Posted 21 Feb 2013 Link to this post

    Hi,

    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
    If I also have columns created in XAML, I can switch those to one of the new column groups, and they will show.

    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
  12. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 22 Feb 2013 Link to this post

    Hi Chad,

    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.

    Greetings,
    Maya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  13. Chad
    Chad avatar
    5 posts
    Member since:
    Feb 2013

    Posted 05 Mar 2013 Link to this post

    Hello Maya,


    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
  14. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 06 Mar 2013 Link to this post

    Hi 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.

Back to Top