I have already trie a bunch of the solutions on the forum, but none of them seem to work. I have a Grid control with a Detail Table contained therein. No matter what I have tried, I cannot hide the column in the detail table. Could it be due to the fact that the column is the data key?
<
telerik:RadGrid
ID
=
"grdAgingReport"
Skin
=
"WebBlue"
EnableEmbeddedSkins
=
"false"
ShowStatusBar
=
"true"
OnSortCommand
=
"grdAgingReport_SortCommand"
OnPageIndexChanged
=
"grdAgingReport_PageIndexChanged"
Width
=
"97%"
OnPageSizeChanged
=
"grdAgingReport_PageSizeChanged"
OnItemCommand
=
"grdAgingReport_ItemCommand"
OnDetailTableDataBind
=
"grdAgingReport_DetailTableDataBind"
OnPreRender
=
"grdAgingReport_PreRender"
AllowSorting
=
"True"
PageSize
=
"15"
AllowPaging
=
"True"
AllowMultiRowSelection
=
"false"
runat
=
"server"
Gridlines
=
"Both"
CssClass
=
"RadGrid_WebBlue"
HierarchyLoadMode
=
"ServerOnDemand"
>
<
ExportSettings
HideStructureColumns
=
"true"
/>
<
MasterTableView
Width
=
"100%"
CommandItemDisplay
=
"Top"
DataKeyNames
=
"MainCategory"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
/>
<
CommandItemSettings
ShowAddNewRecordButton
=
"false"
ShowRefreshButton
=
"false"
ShowExportToWordButton
=
"true"
ShowExportToExcelButton
=
"true"
ShowExportToCsvButton
=
"true"
/>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"SecondaryCategory"
Name
=
"grdTimePeriods"
Width
=
"90%"
HierarchyLoadMode
=
"ServerBind"
></
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
</
telerik:RadGrid
>
protected
void
grdAgingReport_DetailTableDataBind(
object
source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
if
(e.DetailTableView.Name ==
"grdTimePeriods"
)
{
GridDataItem _GridDataItem = (GridDataItem)e.DetailTableView.ParentItem;
string
sMainCategory = _GridDataItem.GetDataKeyValue(
"MainCategory"
).ToString();
e.DetailTableView.DataSource = BuildSecondaryTable(sMainCategory);
//foreach (GridColumn _Column in e.DetailTableView.Columns)
// if (_Column.UniqueName.ToUpper() == "SECONDARYCATEGORY")
// {
// _Column.Display = false;
// break;
// }
}
}
protected
void
grdAgingReport_PreRender(
object
source, EventArgs e)
{
foreach
(GridColumn _Column
in
grdAgingReport.MasterTableView.AutoGeneratedColumns)
{
switch
(_Column.UniqueName.ToUpper())
{
case
"MAINCATEGORY"
:
_Column.Display =
false
;
break
;
}
}
foreach
(GridTableView _GridTableView
in
grdAgingReport.MasterTableView.DetailTables)
if
(_GridTableView.Name ==
"grdTimePeriods"
)
{
if
(_GridTableView.Columns.Count > 0)
_GridTableView.Columns[0].Visible =
false
;
//foreach (GridColumn _Column in _GridTableView.Columns)
//{
// if (_Column.UniqueName.ToUpper() == "SECONDARYCATEGORY")
// _Column.Display = false;
// break;
//}
break
;
}
}