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

Hide Column Header Only

4 Answers 629 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kaka
Top achievements
Rank 1
Kaka asked on 20 Oct 2014, 04:32 AM
Hi,

I want to hide a one header (info header) but not the data like below, is it possible?

===============================
First Name          | Last Name                         --> Header
===============================
First Name 1       | Last Name 1
------------------------------------------------------       --> row 1
Info 1
===============================
First Name 2       | Last Name 2
------------------------------------------------------       --> row 2
Info 2
===============================

Thanks

4 Answers, 1 is accepted

Sort by
0
Ralitsa
Telerik team
answered on 22 Oct 2014, 06:22 AM
Hi Kaka, 

Thank you for contacting us. 

I am not quite sure what is precisely your case. Can you please provide more information on how are you populating RadGridView, are you using some View Definition and precisely which header you would like to hide.

In general, you can hide all column headers by setting the ShowColumnHeaders property to false:
this.radGridView1.ShowColumnHeaders = false;

I am looking forward to your reply.

Regards,
Ralitsa
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Kaka
Top achievements
Rank 1
answered on 22 Oct 2014, 06:59 AM
Hi Ralista,

Yes I'm using ColumnGroupsViewDefinition.

ColumnGroupsViewDefinition view = new ColumnGroupsViewDefinition();
 
view.ColumnGroups.Add(new GridViewColumnGroup("User Details"));
view.ColumnGroups[1].ShowHeader = false;
 
view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Rows[0].Columns.Add(radGridView_Main.Columns["FirstName"]);
 
view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Rows[0].Columns.Add(radGridView_Main.Columns["LastName"]);
 
view.ColumnGroups[1].Rows.Add(new GridViewColumnGroupRow());
view.ColumnGroups[1].Rows[1].Columns.Add(radGridView_Main.Columns["Info"]);


Currently i have this (Current.png), as you can see there is info column. I want to hide the header so it will be like (Result.png).
Is that possible?

Thanks,
0
Accepted
Ralitsa
Telerik team
answered on 24 Oct 2014, 09:53 AM
Hi Kaka, 

Thank you for your reply and provided images which helped me to understand your case better. 

You can subscribe to ViewRowFormatting event and set the Visibility property of Info column to Collapsed and change the MinSize property of another 2 columns (FirstName and LastName). You can use the following code snippet: 
void radGridView1_ViewCellFormatting(object sender, CellFormattingEventArgs e)
        {
            if (sender is GridHeaderCellElement)
            {
                if (e.Column.Name == "Title")
                {
                    e.CellElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
                }
                else
                {
                    e.CellElement.ResetValue(LightVisualElement.VisibilityProperty, Telerik.WinControls.ValueResetFlags.Local);
                }
 
                if (e.Column.Name == "FirstName" || e.Column.Name == "LastName")
                {
                    e.CellElement.MinSize = new Size(0, 57);
                }
                else
                {
                    e.CellElement.ResetValue(LightVisualElement.MinSizeProperty, Telerik.WinControls.ValueResetFlags.Local);
                }
            }
        }

I also attached my sample demo project. 

Should you have further questions, I would be glad to help.

Regards,
Ralitsa
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Kaka
Top achievements
Rank 1
answered on 24 Oct 2014, 11:01 AM
Hi Ralitsa,

Thank you very much, this is what i need.

Tags
GridView
Asked by
Kaka
Top achievements
Rank 1
Answers by
Ralitsa
Telerik team
Kaka
Top achievements
Rank 1
Share this question
or