When I delete a node using the context menu the node doesn't disappear after I rebuild the list of nodes that should be displayed.
In my RadTree I have reports on the 3rd level. I have a context menu that allows me to delete the report at that node. The context menu handler displays a prompt (using RadConfirm). When OK is selected from the prompt, I execute __doPostBack on an asp button. The handler for that button is where the deletion of the report happens (and it does delete it from the database just fine) and then it calls the subroutine that rebuilds the list of reports at that level and then tries to redisplay that on the tree. However the node with the deleted report continues to be displayed.
And in my RadAjaxManager I think I have everything covered: the tree will update the tree and the button updaqtes the tree too.
Any help on this is greatly appreciated. Here are the relevant pieces of code:
Here is the relevant part of the context menu handler:
In my RadTree I have reports on the 3rd level. I have a context menu that allows me to delete the report at that node. The context menu handler displays a prompt (using RadConfirm). When OK is selected from the prompt, I execute __doPostBack on an asp button. The handler for that button is where the deletion of the report happens (and it does delete it from the database just fine) and then it calls the subroutine that rebuilds the list of reports at that level and then tries to redisplay that on the tree. However the node with the deleted report continues to be displayed.
And in my RadAjaxManager I think I have everything covered: the tree will update the tree and the button updaqtes the tree too.
Any help on this is greatly appreciated. Here are the relevant pieces of code:
Here is the relevant part of the context menu handler:
Protected
Sub
rtvReports_ContextMenuItemClick(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.RadTreeViewContextMenuEventArgs)
Select
Case
e.Node.Level
Case
1
'Not important to example
Case
2
Dim
ReportType
As
String
= e.Node.ParentNode.Text
Dim
ReportName
As
String
= e.Node.Text
Dim
Logid
As
String
= e.Node.Value
Dim
ClientID
As
String
= Session(
"ClientID"
)
Select
Case
e.MenuItem.Value
Case
"Delete"
Session(
"CurrentReportTreeNode"
) = e.Node.ParentNode
lbDeleteReportType.Text = e.Node.ParentNode.Text
lbDeleteReportName.Text = e.Node.Text
lbDeleteLogID.Text = e.Node.Value
RadWindowManager1.RadConfirm(
"Delete Report: "
& lbDeleteReportName.Text,
"DeleteReportcallback"
, 300, 100,
Nothing
,
"Delete Report Confirmation"
)
Exit
Select
End
Select
End
Select
End
Sub
Here is the client side function DeleteReportCallBack which seems to work fine:
function
DeleteReportcallback(arg) {
if
(arg ==
true
) {
__doPostBack(
"ctl00$ContentPlaceHolder1$btnDelete"
,
""
);
}
}
Here is the asp button:
<
asp:button
id
=
"btnDelete"
runat
=
"server"
Text
=
""
height
=
0
width
=
"0"
style
=
"background-color:white; border-color:White; border-width:0"
OnCLick
=
"btnDelete_Click"
/>
Here is the button handler and the subroutine that rebuilds the nodes at that level:
Protected
Sub
btnDelete_Click()
Dim
ReportType
As
String
= lbDeleteReportType.Text
Dim
ReportName
As
String
= lbDeleteReportName.Text
Dim
LogID
As
String
= lbDeleteLogID.Text
DeleteReport(LogID, ReportName, ReportType)
Dim
CurrentNode
As
RadTreeNode = Session(
"CurrentReportTreeNode"
)
LoadReports(CurrentNode)
End
Sub
Sub
LoadReports(curnode
As
RadTreeNode)
Dim
ReportType
As
String
= curnode.Text
Dim
ReportTypeParent
As
String
= curnode.ParentNode.Text
Dim
CLientID
As
String
= Session(
"ClientID"
)
Dim
dt
As
New
DataTable
If
curnode.Nodes.Count > 0
Then
For
I
As
Integer
= curnode.Nodes.Count - 1
To
0
Step
-1
curnode.Nodes(I).Remove()
Next
End
If
dt = BindChartNames(ReportType, CLientID)
'Gets the relevant reports from the database
If
dt IsNot
Nothing
And
dt.Rows.Count > 0
Then
dt.DefaultView.Sort =
"ReportName ASC"
For
Each
row
As
DataRow
In
dt.Rows
Dim
node
As
New
RadTreeNode()
node.Text = row(
"ReportName"
).ToString()
node.Value = row(
"LogID"
).ToString()
node.ContextMenuID =
"ReportMenu"
node.HoveredCssClass =
"TreeHover"
curnode.Nodes.Add(node)
Next
curnode.Expanded =
True
curnode.ExpandMode = TreeNodeExpandMode.ClientSide
End
If
End
Sub
And here is the ajax manager and the tree definition (minus some context menus not pertinent to my question):
<
telerik:RadAjaxManager
runat
=
"server"
ID
=
"RadAjaxManager1"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"rtvReports"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"rtvReports"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlDetails"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadMultiPage1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadTabStrip1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlReportType"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
<
telerik:AjaxSetting
AjaxControlID
=
"btnOverwrite"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"rtvReports"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
runat
=
"server"
ID
=
"RadAjaxLoadingPanel1"
Skin
=
"Office2010Black"
InitialDelayTime
=
"400"
/>
<
telerik:RadTreeView
ID
=
"rtvReports"
runat
=
"server"
OnNodeExpand
=
"rtvReports_NodeExpand"
OnContextMenuItemClick
=
"rtvReports_ContextMenuItemClick"
Skin
=
"Office2010Silver"
OnNodeClick
=
"rtvReports_NodeClick"
OnPreRender
=
"rtvReports_PreRender"
>
<
ContextMenus
>
<
telerik:RadTreeViewContextMenu
runat
=
"server"
ID
=
"ReportMenu"
ClickToOpen
=
"True"
>
<
Items
>
<
telerik:RadMenuItem
Text
=
"Edit"
Value
=
"Edit"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
Text
=
"Run"
Value
=
"Run"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
Text
=
"Schedule"
Value
=
"Schedule"
>
</
telerik:RadMenuItem
>
<
telerik:RadMenuItem
Text
=
"Delete"
Value
=
"Delete"
>
</
telerik:RadMenuItem
>
</
Items
>
</
telerik:RadTreeViewContextMenu
>
</
ContextMenus
>
</
telerik:RadTreeView
>
One further note on this issue: I have a Refresh function on the parent node to the reports in the context menu. And after I delete a report node and the node is still there, I run the refresh command from the parent node and it calls the same LoadReports subroutine and it works fine.
Thanks for any help on this.
LoadReports