This question is locked. New answers and comments are not allowed.
Hi,
I am using treeview in my project and I am building the tree at the client side using javascript like this:
<%
Html.Telerik().TreeView()
.Name("PortfolioTreeView")
.ClientEvents(events =>
{
events.OnLoad("FillTree");
})
.Render();
%>
and the javascript function FillTree()
function FillTree(e) {
var tree = treeView(); //Here I get the tree object
var i = 0;
var TreeItems = new Array();
//Here I build the tree from the model, it is build recursively
<% foreach (var Prop in Model)
{ %>
if('<%:Prop.ParentTypeID %>' == 0)
{
var node = {Text: "", ImageUrl: "", Expanded: false, Value: "", Items: []};
node.Text = '<%: Prop.Name%>';
node.Value = '<%: Prop.ID%>' + "|" + "1";
node.ImageUrl = "../../Resources/iPropertyIcons/Properties/PortfolioIcon.png";
FillTreeChildNodes(node, '<%: Prop.ID%>', 1); //To add the child nodes
TreeItems[i] = node;
i = i + 1;
}
<% } %>
//Now I have an array (TreeItems) contains all the items with its children
tree.bindTo(TreeItems);
}
Now the problem is that I want to add actions to these items and I do not know how to do it.
I want each node to call an action when clicked and be able to send the node (Value) to this action.
Thank you in advance for your cooperation.
I am using treeview in my project and I am building the tree at the client side using javascript like this:
<%
Html.Telerik().TreeView()
.Name("PortfolioTreeView")
.ClientEvents(events =>
{
events.OnLoad("FillTree");
})
.Render();
%>
and the javascript function FillTree()
function FillTree(e) {
var tree = treeView(); //Here I get the tree object
var i = 0;
var TreeItems = new Array();
//Here I build the tree from the model, it is build recursively
<% foreach (var Prop in Model)
{ %>
if('<%:Prop.ParentTypeID %>' == 0)
{
var node = {Text: "", ImageUrl: "", Expanded: false, Value: "", Items: []};
node.Text = '<%: Prop.Name%>';
node.Value = '<%: Prop.ID%>' + "|" + "1";
node.ImageUrl = "../../Resources/iPropertyIcons/Properties/PortfolioIcon.png";
FillTreeChildNodes(node, '<%: Prop.ID%>', 1); //To add the child nodes
TreeItems[i] = node;
i = i + 1;
}
<% } %>
//Now I have an array (TreeItems) contains all the items with its children
tree.bindTo(TreeItems);
}
Now the problem is that I want to add actions to these items and I do not know how to do it.
I want each node to call an action when clicked and be able to send the node (Value) to this action.
Thank you in advance for your cooperation.