Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IActionResult GetTree()
- {
- IList<Node> tree = new List<Node>();
- Node GNode = new Node() { text = "A" };
- Node childNode = new Node()
- {
- text = "A tree Node",
- icon = Url.Content("~/images/pdf.gif"),
- a_attr = new { href = "http://www.google.com", target = "_blank", onclick = "window.open(this.href);" }
- };
- GNode.children.Add(childNode);
- tree.Add(GNode);
- return Json(tree);
- }
- <div id="Tree" class="tree"></div>
- @section Scripts{
- <script src="~/lib/jquery/dist/jquery.min.js"></script>
- <script src="~/js/jstree.min.js"></script>
- <script type="text/javascript">
- $(function () {
- $('#Tree').jstree({
- 'plugins': ["search"],
- 'core': {
- 'data': {
- url: "@Url.Action("GetTree", "Home")",
- type: "Post",
- success: function (data) {
- alert("success")
- }
- }
- }
- });
- });
- </script>
- }
Add Comment
Please, Sign In to add comment