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

Show/Hide ColumnGroups

1 Answer 318 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Savi
Top achievements
Rank 1
Savi asked on 28 Jul 2016, 07:23 AM
I've got a RadGrid with programmatically generated columns, including a variable number of column groups.
 Each of the column groups contains two/three columns, and I want to hide the columns along with the associated ColumnGroup.
Above the RadGrid I have a series of checkboxes, one for each column group. The goal is to have the user
 check or uncheck the boxes depending on what columns they wish to see. Currently I am setting the columns
' Display properties when a checkbox's checked value is changed by using 
radgrid.Columns.FindByUniqueName("columnName").Display.

And also tried radgrid.MasterTableView.ColumnGroups.FindGroupByName("colGroupname").Display = False but there is no 
Display property for that and the Visible property is ReadOnly. So I managed to hide ColumnGroup by applying
CSS class to hide the Column group.

But the export to excel is not reflecting the hidden group and also it reshuffles the columns into excel file.
So please suggest the option to hide the Column group into export file or any alternate option to achieve the same.

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 02 Aug 2016, 06:58 AM
Hi Savi,

Try to use the ItemCommand event to capture the e.CommandName == RadGridPdfExportCommand argument and hide them again. Or use the PreRender event handler of the grid with the RadGrid1.IsExporting condition in an if statement and then hide the required elements. Also, you can try to hide the columns directly, not the ColGroups:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/using-the--getitems-getcolumn-and-getcolumnsafe-methods

Regards,
Eyup
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
Savi
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or