Merging of header in radgridview

22 posts, 0 answers
  1. rajeev kumar
    rajeev kumar avatar
    16 posts
    Member since:
    Oct 2009

    Posted 29 Oct 2009 Link to this post

    I want to merge header of column in radgridview.For example: 'Name' is header group, under which 3 headers 'First Name', 'Middle Name' and 'Last Name' are available. We are able to merge and group headers using header style and datatemplate for header. But, by using this, it lost all gridview functinality like I am not able to do filtering or sorting on column under header 'First Name' or 'last Name' etc. Please help me to resolve this issue. It is urgent.
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 03 Nov 2009 Link to this post

    Hello rajeev kumar,

    This feature is not yeat internally supported by RadGridView. However there are different workarrounds.
    In the attached example a common header is rendered above the normal headers thus preserving the sorting and filtering functions of the grid.

    Kind regards,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WPF is Visual Studio 2017 Ready
  4. bhaskar
    bhaskar avatar
    9 posts
    Member since:
    May 2009

    Posted 25 Nov 2009 Link to this post

    Hi Pavel Pavlov ,
     
    Thanks for the post.I also have the same requirement with telerik asp.net ajax radgrid.Could you please provide the solution for this.really urgent.with out missing any grid functionality need to merge the columns.

    Thanks in Advance,
    Bhaskar.  

    I have tried but all the grid functionality is not working properly.please have a look into the code.

    public void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
            {
                if (e.Item.ItemType == GridItemType.Header)
                {
                    RadGrid RadGrid1 = (RadGrid)sender;
                    GridHeaderItem headerRow = new GridHeaderItem(RadGrid1.MasterTableView, 0, 0);

                    // Extra Cell added at the Beginning
                    GridTableHeaderCell headerCell = new GridTableHeaderCell();
                    headerCell.HorizontalAlign = HorizontalAlign.Center;
                    headerCell.Text = " ";
                    headerRow.Cells.Add(headerCell);

                    // Extra Cell added at the Beginning
                    headerCell = new GridTableHeaderCell();
                    headerCell.Text = " ";
                    headerRow.Cells.Add(headerCell);

                    //// First grouping
                    //headerCell = new GridTableHeaderCell();
                    //headerCell.HorizontalAlign = HorizontalAlign.Center;
                    //headerCell.Text = e.Item.Cells[2].Text; // Removing extra cell
                    //headerCell.RowSpan = 2;
                    //headerRow.Cells.Add(headerCell);
                    //e.Item.Cells.RemoveAt(2);
                
                        headerCell = new GridTableHeaderCell();
                        headerCell.HorizontalAlign = HorizontalAlign.Center;
                        headerCell.Text = "";
                        headerCell.ColumnSpan = 1;
                        headerRow.Cells.Add(headerCell);

                        headerCell = new GridTableHeaderCell();
                        headerCell.HorizontalAlign = HorizontalAlign.Center;
                        headerCell.Text = "";
                        headerCell.ColumnSpan = 1;
                        headerRow.Cells.Add(headerCell);

                        headerCell = new GridTableHeaderCell();
                        headerCell.HorizontalAlign = HorizontalAlign.Center;
                        headerCell.Text = "Basecase";
                        headerCell.ColumnSpan = 1;
                        headerRow.Cells.Add(headerCell);

                        headerCell = new GridTableHeaderCell();
                        headerCell.HorizontalAlign = HorizontalAlign.Center;
                        headerCell.Text = "Case1";
                        headerCell.ColumnSpan =1;
                        headerRow.Cells.Add(headerCell);
                   
                    GridTHead gridTHead = e.Item.Parent as GridTHead;
                    if (gridTHead != null)
                    {
                        // Adding the header row to group columns.
                        gridTHead.Controls.AddAt(0, headerRow);
                    }
                  
                }
            }

     
  5. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 26 Nov 2009 Link to this post

    Hi,

    This forum is for our WPF grid - you can post your questions in the relevant forum!

    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. rajeev kumar
    rajeev kumar avatar
    16 posts
    Member since:
    Oct 2009

    Posted 14 Dec 2009 Link to this post

    Hi Pavel Pavlov,
            Thanks for your solution. I am able to achieve the grouping functionality. I am facing one problem >
    I have one more column header 'Conatct No.'  that does not belong to group column header 'Name'. I do not want to move that column inside the group column header 'Name'. Even I do not want to move column under header 'Name' to move out of group.But we can move columns under one header group like 'First Name', 'Middle Name' and 'Last Name' column order . How to do solve this problem. Please give some solution.

    Regards,
    Rajeev
  7. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 14 Dec 2009 Link to this post

    Hello rajeev kumar,

    I have provided an updated sample ( with the latest version of RadGridview) . I believe it gives more power and control over column grouping . You may find it helpful.

    You may find the article here http://blogs.telerik.com/pavelpavlov/posts/09-12-04/adding_additional_power_to_radgridview_for_silverlight_with_attached_behaviors.aspx


    Best wishes,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  8. rajeev kumar
    rajeev kumar avatar
    16 posts
    Member since:
    Oct 2009

    Posted 15 Jan 2010 Link to this post

    Hi Pavel,
                I have seen ur sample. Thanks for ur response. But, I want the reordering functionality also. So, I am following ur first sample. But, I am facing one problem. I have two group header:- 'Office Address' and 'Home Address' . I want the background color or font color of these two header should be different.How to set this. I am not able set different style for these two header.Can u please give some solution to this. Thanks in advance.


    Regards,
    Rajeev
              
  9. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 19 Jan 2010 Link to this post

    Hi rajeev kumar,

    The attached example demonstrates how you can change the background of a common header.
    This is generally the project from my blog with a few changes.
    The changed files are MainPage.cs and CommonHeader.cs

    Let me know if you find troubles adapting this to your project.

    Kind regards,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  10. rajeev kumar
    rajeev kumar avatar
    16 posts
    Member since:
    Oct 2009

    Posted 22 Jan 2010 Link to this post

    Hi Pavel,
            Thank you for ur response. I have tried ur solution, but u r hiding the column header. But, I want column header also to be displayed below group header.(columngroups2.zip as in this solution).So, please give some suggestion.

    Regards,
    Rajeev
  11. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 22 Jan 2010 Link to this post

    Hello rajeev kumar,

    I am a bit confused.There seems to be a kind of misunderstanding. I definitely do not hide the column headers. Please see the image attached.
    Column headers are there ( marked with the text "regular column headers").

    Kind regards,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  12. rajeev kumar
    rajeev kumar avatar
    16 posts
    Member since:
    Oct 2009

    Posted 26 Jan 2010 Link to this post

    Hi Pavel,
            Thank you for ur response. I have tried ur solution, it is working fine for silverlight. But when I tried to convert it into WPF, I am not able to see the column header. Can you please give that solution for WPF. I have used same way whatever u have used. I have tried to attach .zip file of solution for ur reference purpose, but not able to attach. Please give some suggestion.

    Regards,
    Rajeev
  13. rajeev kumar
    rajeev kumar avatar
    16 posts
    Member since:
    Oct 2009

    Posted 28 Jan 2010 Link to this post

    Hi Pavel,
            Thank you for ur response. I have tried ur solution, it is working fine for silverlight. But when I tried to convert it into WPF, I am not able to see the column header.Actaully column header got overlap by group header.How to overcome this problem.Please suggest.Even I think that grid functionality are missing (like sorting, grouping,filtering). Please give some suggestion.
    Regards,
     Rajeev
  14. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 01 Feb 2010 Link to this post

    Hi rajeev kumar,

    I am sending attached the example from the blog , converterd to WPF.  I believe everything is working OK - no overlapping, no missing functionallity as filtering or sorting .

    Let me know if you need further assistance.

    Sincerely yours,
    Pavel Pavlov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  15. rajeev kumar
    rajeev kumar avatar
    16 posts
    Member since:
    Oct 2009

    Posted 01 Feb 2010 Link to this post

     

    Hi Pavel,
            Thank you for ur response. I have tried ur solution, it is working fine.But if I am putting Background="Green" for CommonHeader tag in "Window1.xaml", then also the background color of group header is not changing to green. I do not know the cause behind that. Please see and give some solution.
    Regards,
     Rajeev
  16. rajesh singh
    rajesh singh avatar
    3 posts
    Member since:
    Feb 2010

    Posted 25 Feb 2010 Link to this post

    Hi Pavel ,

              I  also have same kind of requirement, what rajeev has. I have implemented ur solution. I am also getting same problem as Rajeev. I am not able to change the background color by putting Background="Green" for CommonHeader tag in "Window1.xaml" file whatever u have shared. Is some where it got overriden. Can u also try and let me know, is it working for u or not. If not, then let me know.
    Thanks u in advance.
    Rajesh.

  17. rajeev kumar
    rajeev kumar avatar
    16 posts
    Member since:
    Oct 2009

    Posted 05 Apr 2010 Link to this post

    Hi Pavel,
                The solution columnheadergroups-wpf.zip u have provided is working fine, but the grid is not supporting drag and drop of columns functionality( reordering of columns). I am not able to reorder the column. Can u please give some solution. Thanks in advance.

    Regards,
    Rajeev Kumar
  18. Eduan Marais
    Eduan Marais avatar
    18 posts
    Member since:
    Feb 2010

    Posted 07 Jul 2010 Link to this post

    Thanks for the WPF Example.

    I modified it a bit, as I needed to create the Common Headers in runtime, based on values passed through a dataset.
    I do experience a problem though.

    The Common headers does not show until you clicked on the Filter on a column and selected SELECT ALL. ??

    I think because you are adding the Common Columns in your xaml, you do not have this issue.
    Is there some property that I need to set to show the Common columns straight away?

    I think one way to bypass the issue is to fire the FILTERED event manually, but I do not know how... ? :-(

    Please assist if possible.

    Thx
    Eduan

  19. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 07 Jul 2010 Link to this post

    Hello Eduan Marais,

    Let me see your code . This way I can find what is causing the trouble and provide the modifications necessary.
     An alternative is to send me your project and let me fix it for you . To be able to attach it , you will need to open a support ticket.

    Best wishes,
    Pavel Pavlov
    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
  20. Eduan Marais
    Eduan Marais avatar
    18 posts
    Member since:
    Feb 2010

    Posted 08 Jul 2010 Link to this post

    HI Pavel,

    I have created a support ticket, ref no 325987.
    I have attached the enitre project. Please ignore all the logic irrellevant to the issue.

    Thanks, looking forward to your reply

    Eduan
  21. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 08 Jul 2010 Link to this post

    Hello Eduan Marais,
    As mentioned in the support relevant support ticket ,
    the solution is to modify the code in ColumnGroupsBehaviour.cs
    as following:
    1. Remove the hadling of the DataLoaded event

    2. Substitute it  the following way:
    protected override void OnAttached()
          {
              base.OnAttached();
              var grid = this.AssociatedObject.ChildrenOfType<Grid>().Where(c => c.Name == "HierrarchyBackground").FirstOrDefault();
              if (grid != null)
                  PlaceSecondaryHeader();
              this.AssociatedObject.LayoutUpdated += new EventHandler(AssociatedObject_LayoutUpdated);
          }
          void AssociatedObject_LayoutUpdated(object sender, EventArgs e)
          {
              var grid = this.AssociatedObject.ChildrenOfType<Grid>().Where(c => c.Name == "HierrarchyBackground").FirstOrDefault();
              if (grid != null)
              {
                  this.AssociatedObject.LayoutUpdated -= new EventHandler(AssociatedObject_LayoutUpdated);
                  PlaceSecondaryHeader();
              }
          }


    Best wishes,
    Pavel Pavlov
    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
  22. Siva Prakash
    Siva Prakash avatar
    14 posts
    Member since:
    Sep 2011

    Posted 05 Jan 2012 Link to this post

    Hi,

    I have a requirement some what like this.

    ----------------------------------------------------------------------------
    |      Coordinates |                     |                    |                        |
    |---------------------|    Width (m)  |   Height(m) |  Efficienty (%)  |
    |    X(m) |   Y(m)   |                     |                   |                         |
    ----------------------------------------------------------------------------
    Is this type of header column merging feature possible ?
    I got the latest Q3 Telerik WPF 4.0 dll's.  In that one header column merging feature was introudced. But its not serving me this type of functionality. Its showing somewhat like this.

    ----------------------------------------------------------------------------
    |      Coordinates |                     |                    |                        |
    |---------------------| ----------------|----------------|-------------------|
    |    X(m) |   Y(m)   |   Width (m)   |  Height(m)  | Efficienty (%)  |
    ----------------------------------------------------------------------------

    So please help me out in implementing this.

    Thanks & Regards
    K Siva Prakash.
  23. Black
    Black avatar
    1 posts
    Member since:
    Nov 2011

    Posted 26 Jan 2012 Link to this post

    Hello,

    I have to use your solution because my client doesn't want to upgrade telerik to have the new option for grouping headers.

    Your solution works very well, but I have a problem.

    I need to bind the text on the Caption, and It doesn't work...

    <telerik:RadGridView Grid.Column="2" AutoGenerateColumns="False" ShowGroupPanel="False" IsSynchronizedWithCurrentItem="True" IsReadOnly="True" ItemsSource="{Binding MyListe}" Height="750" CanUserDeleteRows="False" Margin="10,10,20,20" ScrollViewer.VerticalScrollBarVisibility="Auto">
                        <i:Interaction.Behaviors>
                            <local:ColumnGroupsBehavior>
                                <local:ColumnGroupsBehavior.CommonHeaders>
                                    <local:UserControlCommonHeader StartColumnIndex="0" Caption="{Binding CurrentTranslation[lbl_cars]}" ColumnSpan="4" />
                                    <local:UserControlCommonHeader StartColumnIndex="4" Caption="train" ColumnSpan="2" />
                                    <local:UserControlCommonHeader StartColumnIndex="6" Caption="plane"  ColumnSpan="6" />
                                </local:ColumnGroupsBehavior.CommonHeaders>
                            </local:ColumnGroupsBehavior>
                        </i:Interaction.Behaviors>
    </telerik:RadGridView>

    How can I do that??

    I have an other problem, I want to set the property RowIndicatorVisibility="Collapsed" in the gridview but the top header keep this, and so columns are not well design.

    Thanks a lot...
Back to Top
UI for WPF is Visual Studio 2017 Ready