Why do each of the items in a self-referencing hierarchy grid have child columns displayed -- even when there are no children for the item? (Note: I *do* want a row columns displayed if there are child items, just not displayed when there are *no* children.)
I'm implementing a radgrid in 508 mode where the child row column headers are displayed (along with the main column headers). What I want displayed is as follows:
Parent Column 1 | Parent Column 2 | Parent Column 3
Parent row ............
Child Column 1 | Child Column 2 | Child Column 3
Child row .............
Child Column 1 | Child Column 2 | Child Column 3
Child row .............
However, when there's only one child, the following is displayed:
Parent Column 1 | Parent Column 2 | Parent Column 3
Parent row ............
Child Column 1 | Child Column 2 | Child Column 3
Child row .............
Child Column 1 | Child Column 2 | Child Column 3
As you can see, the Child Column headers are showing up childCount + 1 times (if there are no children, a child header row appears anyway).
I've tried hiding the column headers on the ItemCreated event, but haven't been successful.
Here's the code definition corresponding to the grid:
The code behind for the ItemCreated is as follows:
I'm implementing a radgrid in 508 mode where the child row column headers are displayed (along with the main column headers). What I want displayed is as follows:
Parent Column 1 | Parent Column 2 | Parent Column 3
Parent row ............
Child Column 1 | Child Column 2 | Child Column 3
Child row .............
Child Column 1 | Child Column 2 | Child Column 3
Child row .............
However, when there's only one child, the following is displayed:
Parent Column 1 | Parent Column 2 | Parent Column 3
Parent row ............
Child Column 1 | Child Column 2 | Child Column 3
Child row .............
Child Column 1 | Child Column 2 | Child Column 3
As you can see, the Child Column headers are showing up childCount + 1 times (if there are no children, a child header row appears anyway).
I've tried hiding the column headers on the ItemCreated event, but haven't been successful.
Here's the code definition corresponding to the grid:
<
telerik:RadGrid
ID
=
"grdNotes"
runat
=
"server"
OnColumnCreated
=
"grdNotes_ColumnCreated"
OnItemCreated
=
"grdNotes_ItemCreated"
OnItemDataBound
=
"grdNotes_ItemDataBound"
OnNeedDataSource
=
"grdNotes_NeedDataSource"
OnPreRender
=
"grdNotes_PreRender"
AutoGenerateColumns
=
"False"
SkinID
=
"HierarchicalGrid"
GridLines
=
"None"
AllowCustomPaging
=
"True"
ShowStatusBar
=
"True"
PageSize
=
"20"
Width
=
"100%"
EnableLinqExpressions
=
"False"
>
<
HeaderContextMenu
EnableTheming
=
"True"
>
<
CollapseAnimation
Type
=
"OutQuint"
Duration
=
"200"
></
CollapseAnimation
>
</
HeaderContextMenu
>
<
ClientSettings
Selecting-AllowRowSelect
=
"true"
Resizing-AllowColumnResize
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
<
ClientEvents
OnRowSelected
=
"NoteRowSelected"
OnRowContextMenu
=
"NoteContextMenu"
OnRowDblClick
=
"grdNotes_OnRowDblClick"
OnColumnResized
=
"ResizeAllNoteColumns"
OnGridCreated
=
"NotePageLoad"
/>
<
Resizing
AllowColumnResize
=
"True"
></
Resizing
>
</
ClientSettings
>
<
PagerStyle
Position
=
"Bottom"
AlwaysVisible
=
"True"
Mode
=
"NextPrevAndNumeric"
Wrap
=
"False"
BackColor
=
"White"
Font-Size
=
"Large"
/>
<
MasterTableView
HierarchyDefaultExpanded
=
"true"
HierarchyLoadMode
=
"Client"
AllowSorting
=
"true"
DataKeyNames
=
"Id,ParentId,Token,IsRoot,Replies,NoteCreator"
ClientDataKeyNames
=
"Id,ParentId,Token,IsRoot,Replies,NoteCreator"
NoDetailRecordsText
=
""
EnbleNoRecordsTemplate
=
"True"
Width
=
"100%"
>
<
SelfHierarchySettings
ParentKeyName
=
"ParentId"
KeyName
=
"Id"
MaximumDepth
=
"20"
/>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
Columns
>
<
telerik:GridClientSelectColumn
DataTextField
=
"Id"
HeaderAbbr
=
"Select"
HeaderButtonType
=
"TextButton"
HeaderText
=
"Select"
HeaderTooltip
=
"Select/Deselect"
Text
=
"Select"
Visible
=
"false"
UniqueName
=
"asgSelect"
HeaderStyle-Width
=
"7%"
>
<
HeaderStyle
Width
=
"7%"
></
HeaderStyle
>
</
telerik:GridClientSelectColumn
>
<
telerik:GridBoundColumn
DataField
=
"Id"
HeaderText
=
"Id"
SortExpression
=
"Id"
UniqueName
=
"Id"
HeaderStyle-Width
=
"5%"
>
<
HeaderStyle
Width
=
"5%"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Title"
HeaderText
=
"Title"
SortExpression
=
"Title"
UniqueName
=
"Title"
HeaderStyle-Width
=
"20%"
>
<
HeaderStyle
Width
=
"20%"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Body"
HeaderText
=
"Body"
SortExpression
=
"Body"
UniqueName
=
"Body"
HeaderStyle-Width
=
"37%"
>
<
HeaderStyle
Width
=
"37%"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CreatedBy"
HeaderText
=
"Created By"
SortExpression
=
"CreatedBy"
UniqueName
=
"CreatedBy"
HeaderStyle-Width
=
"10%"
>
<
HeaderStyle
Width
=
"10%"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"CreatedDate"
HeaderText
=
"Created On"
SortExpression
=
"CreatedDate"
UniqueName
=
"CreatedOn"
HeaderStyle-Width
=
"10%"
>
<
HeaderStyle
Width
=
"10%"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ParentId"
HeaderText
=
"Parent Id"
SortExpression
=
"ParentId"
UniqueName
=
"ParentId"
Visible
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"Token"
HeaderText
=
"Token"
SortExpression
=
"Token"
UniqueName
=
"Token"
Visible
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"IsRoot"
HeaderText
=
"IsRoot"
SortExpression
=
"IsRoot"
UniqueName
=
"IsRoot"
Visible
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"Replies"
HeaderText
=
"Replies"
SortExpression
=
"Replies"
UniqueName
=
"Replies"
Visible
=
"false"
/>
<
telerik:GridBoundColumn
DataField
=
"NoteCreator"
HeaderText
=
"NoteCreator"
SortExpression
=
"NoteCreator"
UniqueName
=
"NoteCreator"
Visible
=
"false"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"Actions"
HeaderStyle-Width
=
"15%"
HeaderText
=
"Actions"
Visible
=
"false"
>
<
ItemTemplate
>
<
telerik:RadToolBar
ID
=
"rtbNoteActions"
runat
=
"server"
SkinID
=
"ActionToolbar"
OnButtonClick
=
"NotesGridToolbarButtonClicked"
OnClientButtonClicking
=
"NoteActionToolbarClicking"
>
<
Items
>
<
telerik:RadToolBarButton
Text
=
"Properties"
CommandName
=
"Properties"
ImageUrl
=
"~/Images/page_view.gif"
/>
<
telerik:RadToolBarButton
Text
=
"Reply"
CommandName
=
"Reply"
ImageUrl
=
"~/Images/page_edit.gif"
/>
<
telerik:RadToolBarButton
Text
=
"Security"
CommandName
=
"Security"
ImageUrl
=
"~/Images/shield16.gif"
/>
<
telerik:RadToolBarButton
Text
=
"Delete"
CommandName
=
"Delete"
ImageUrl
=
"~/Images/delete16.gif"
/>
</
Items
>
</
telerik:RadToolBar
>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"15%"
></
HeaderStyle
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
PagerStyle
AlwaysVisible
=
"True"
></
PagerStyle
>
</
MasterTableView
>
<
FilterMenu
EnableTheming
=
"True"
>
<
CollapseAnimation
Type
=
"OutQuint"
Duration
=
"200"
></
CollapseAnimation
>
</
FilterMenu
>
</
telerik:RadGrid
>
The code behind for the ItemCreated is as follows:
protected
void
grdNotes_ItemCreated(
object
sender, GridItemEventArgs e)
{
CreateExpandCollapseButton(e.Item,
"Id"
);
if
(e.Item
is
GridHeaderItem && e.Item.OwnerTableView != grdNotes.MasterTableView)
{
if
(!CachedApplicationData.UseAssistiveTechnology)
{
e.Item.Style[
"display"
] =
"none"
;
}
}
if
(e.Item
is
GridNestedViewItem)
{
e.Item.Cells[0].Visible =
false
;
e.Item.Cells[1].Style.Add(HtmlTextWriterStyle.Padding,
"0px"
);
}
}