The C1Menu control can be used as a context menu for most of the other ComponentOne controls. This topic will walk you through displaying a C1Menu control as a context menu for a C1TreeView control.
Complete the following steps:
<cc1:C1Menu>
tags:
OnClientSelect
onclientselect="C1Menu_OnClientSelect" Orientation="Vertical"
Trigger="#C1TreeView1" TriggerEvent="Rtclick"
The complete opening tag markup should resemble the following:
To write code in Source View
<cc1:C1Menu ID="C1Menu1" runat="server"
onclientselect="C1Menu_OnClientSelect" Orientation="Vertical"
Trigger="#C1TreeView1" TriggerEvent="Rtclick">
<cc1:C1TreeView>
tags and add the following markup between the tags:
To write code in Source View
<Nodes>
<cc1:C1TreeViewNode runat="server" CheckState="UnChecked" NodeIndex="0"
Text="Node1">
<Nodes>
<cc1:C1TreeViewNode runat="server" CheckState="UnChecked" NodeIndex="0"
Text="SubNode1">
</cc1:C1TreeViewNode>
<cc1:C1TreeViewNode runat="server" CheckState="UnChecked" NodeIndex="0"
Text="SubNode2">
</cc1:C1TreeViewNode>
</Nodes>
</cc1:C1TreeViewNode>
<cc1:C1TreeViewNode runat="server" CheckState="UnChecked" NodeIndex="0"
Text="Node2">
<Nodes>
<cc1:C1TreeViewNode runat="server" CheckState="UnChecked" NodeIndex="0"
Text="SubNode1">
</cc1:C1TreeViewNode>
<cc1:C1TreeViewNode runat="server" CheckState="UnChecked" NodeIndex="0"
Text="SubNode2">
</cc1:C1TreeViewNode>
</Nodes>
</cc1:C1TreeViewNode>
</Nodes>
To write code in Source View
<script type="text/javascript">
$(document).ready(function () {
$(".wijmo-wijtree-node").mousedown(function (e) {
if (e.button == 2)
$(this).arent().c1treeviewnode("option", "selected", "true");
});
});
function C1Menu_OnClientSelect(sender, args) {
alert("You have selected " + args.item[0].innerText);
}
</script>