or
Forget it. The template I was working from was done by another programmer who I don't have contact with ... or trust.


<telerik:RadGrid ID="RadGrid1" runat="server" Skin="Web20" OnItemCreated="RadGrid1_ItemCreated" OnItemDataBound="RadGrid1_ItemDataBound" OnColumnCreated="RadGrid1_ColumnCreated" AutoGenerateColumns="False" ShowStatusBar="True" CellSpacing="0" GridLines="None" AllowAutomaticInserts="True"> <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu> <MasterTableView DataKeyNames="CATEGORY_CDE, PARENT_CDE" ShowHeader="true" HierarchyDefaultExpanded="false" AllowSorting="true" CommandItemDisplay="Bottom" editmode="InPlace" InsertItemDisplay="Bottom"> <SelfHierarchySettings KeyName="CATEGORY_CDE" ParentKeyName="PARENT_CDE" /> <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add New Category"></CommandItemSettings> <Columns> <telerik:GridExpandColumn FilterControlAltText="Filter ExpandColumn column" Visible="True"> </telerik:GridExpandColumn> <telerik:GridEditCommandColumn UniqueName="UpdateColumn" FilterControlAltText="Filter EditCommandColumn column" Visible="True" EditText="" InsertText="" CancelText="" ButtonType="ImageButton" EditImageUrl="../images/blank.gif"> </telerik:GridEditCommandColumn> <telerik:GridBoundColumn DataField="Category_Cde" UniqueName="Category_Cde" Visible="true"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="Parent_cde" UniqueName="Parent_cde" Visible="true"> </telerik:GridBoundColumn> </Columns> <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings> <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"> <HeaderStyle Width="20px"></HeaderStyle> </RowIndicatorColumn> <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True"> <HeaderStyle Width="20px"></HeaderStyle> </ExpandCollapseColumn> <EditFormSettings> <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn> </EditFormSettings> </MasterTableView> <ClientSettings AllowExpandCollapse="true" /> <FilterMenu EnableImageSprites="False"></FilterMenu> </telerik:RadGrid>Protected Sub RadGrid1_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand Dim itemKey As String 'Inactivates non selected hierarchy levels If (e.CommandName = RadGrid.ExpandCollapseCommandName) Then Dim currentItem As GridDataItem = DirectCast(e.Item, GridDataItem) Dim currentRowIndex As Integer = currentItem.ItemIndex Dim currentCatKey As String = currentItem.GetDataKeyValue("CATEGORY_CDE").ToString() Dim currentParentKey As String = currentItem.GetDataKeyValue("PARENT_CDE").ToString() If (Not currentItem.Expanded) Then 'If an item is expanded then hide the other rows at that level For Each ditem As GridDataItem In RadGrid1.Items itemKey = ditem.GetDataKeyValue("PARENT_CDE").ToString() If currentRowIndex <> ditem.ItemIndex And currentParentKey = ditem.GetDataKeyValue("PARENT_CDE").ToString() Then 'Trying to find the right way to suppress the option to add categories for unopened levels 'RadGrid1.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = False 'RadGrid1.MasterTableView.CommandItemSettings.ShowRefreshButton = False ' RadGrid1.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.None 'RadGrid1.AllowAutomaticInserts = False
'Enables the fields for the row EnableDisableItem(ditem, True)
ditem.Visible = False
Else 'Disables the fields for the row EnableDisableItem(ditem, False) End If Next Else For Each ditem As GridDataItem In RadGrid1.Items itemKey = ditem.GetDataKeyValue("PARENT_CDE").ToString() If currentParentKey = ditem.GetDataKeyValue("PARENT_CDE").ToString() Then ditem.Visible = True 'Enables fields for row EnableDisableItem(ditem, True) End If Next End If End If If (e.CommandName = "PerformInsert") Then e.Canceled = True Dim dgi As GridDataInsertItem = TryCast(e.Item, GridDataInsertItem) updateCategory("AddCat", dgi) RadGrid1.EditIndexes.Clear() RadGrid1.Rebind() End If rbtnSave.Visible = TrueEnd Sub