Sunday, 15 September 2013

c# - ASP MVC View. Making a tree look like a tree -



c# - ASP MVC View. Making a tree look like a tree -

a little bit of background consider not relevant question might useful. controller should display tree gets root node wcf service, node implemented way, , returns list of children of node.

[datacontract] public class node { [datamember] public int nodeid { get; set; } [datamember] public string name { get; set; } [datamember] public int parentid { get; set; } [datamember] public list<node> children; }

now of import part. want tree tree in view, tried write sort of recursive razor helper based on illustration found on

@helper displaytree(ienumerable<project.userservice.node> nodes) { foreach (var item in nodes) { <tr> <td> @html.displayfor(modelitem => item.name) </td> <td> @html.actionlink("edit", "edit", new { id = item.nodeid }) | @html.actionlink("details", "details", new { id = item.nodeid }) | @html.actionlink("delete", "delete", new { id = item.nodeid }) </td> </tr> if(item.children.any()) { @displaytree(item.children) } } @displaytree(model)

the model list of children of root node. view displays nodes nowadays in tree, want actual tree. don't how describe blunt explanation want reminiscent of file tree in windows cmd. want without using except c# , razor, , when googled results involved using jquery or js don't now. give me hint in right direction, please ?

c# asp.net-mvc razor

No comments:

Post a Comment