Guest User

Untitled

a guest
Mar 20th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. public IActionResult GetTree()
  2. {
  3. IList<Node> tree = new List<Node>();
  4. Node GNode = new Node() { text = "A" };
  5. Node childNode = new Node()
  6. {
  7. text = "A tree Node",
  8. icon = Url.Content("~/images/pdf.gif"),
  9. a_attr = new { href = "http://www.google.com", target = "_blank", onclick = "window.open(this.href);" }
  10. };
  11.  
  12. GNode.children.Add(childNode);
  13. tree.Add(GNode);
  14.  
  15. return Json(tree);
  16. }
  17.  
  18. <div id="Tree" class="tree"></div>
  19. @section Scripts{
  20. <script src="~/lib/jquery/dist/jquery.min.js"></script>
  21. <script src="~/js/jstree.min.js"></script>
  22. <script type="text/javascript">
  23. $(function () {
  24. $('#Tree').jstree({
  25. 'plugins': ["search"],
  26. 'core': {
  27. 'data': {
  28. url: "@Url.Action("GetTree", "Home")",
  29. type: "Post",
  30. success: function (data) {
  31. alert("success")
  32. }
  33. }
  34. }
  35. });
  36. });
  37. </script>
  38. }
Add Comment
Please, Sign In to add comment