I have a RADTreeView that I build programmatically.
The same RADTreeView has ContextMenus built during design time. I've attached the script below on the RADTreeview's OnClientContextMenuShowing as below. The issue I have is that this only works for the nodes that have "isApproved" attributes. If right-click anywhere else in the RADTreeView, I get an error that says "Unable to get value of the property 'get_id': object is null or undefined".
My concept is that the get_id method shouldn't be called unless the context menu id is what I have stated below. It seems to be getting called not matter what. Your help is appreciated.
The same RADTreeView has ContextMenus built during design time. I've attached the script below on the RADTreeview's OnClientContextMenuShowing as below. The issue I have is that this only works for the nodes that have "isApproved" attributes. If right-click anywhere else in the RADTreeView, I get an error that says "Unable to get value of the property 'get_id': object is null or undefined".
My concept is that the get_id method shouldn't be called unless the context menu id is what I have stated below. It seems to be getting called not matter what. Your help is appreciated.
<telerik:RadTreeView ID="RadTreeView1" runat="server" OnClientContextMenuShowing="ClientContextMenuShowing">
<telerik:RadCodeBlock ID=
"RadCodeBlock1"
runat=
"server"
>
<script type=
"text/javascript"
language=
"javascript"
>
function
ClientContextMenuShowing(sender, eventArgs) {
var
node = eventArgs.get_node();
var
menu = eventArgs.get_menu();
var
domEvent = eventArgs.get_domEvent();
/* Change value of context menu based on whether an item is approved or not is Consent
Agenda */
if
(menu.get_id() ==
"ctl00_ContentPlaceHolder1_RadTreeView1_cmOtherApprovalsAgenda"
) {
var
attributes = node.get_attributes();
attributes.getAttribute(
"isApproved"
);
if
(attributes.getAttribute(
"isApproved"
) ==
"Yes"
) {
menu.findItemByValue(
"cmOtherApprovalsAgendaApproveAB"
).set_text(
"UnApprove Agenda Bill"
);
}
else
{
menu.findItemByValue(
"cmOtherApprovalsAgendaApproveAB"
).set_text(
"Approve Agenda Bill"
);
}
}
}
</script>
</telerik:RadCodeBlock>