This question is locked. New answers and comments are not allowed.
Hi
I am trying to populate the treeview by making an Ajax call. I am getting the following hierarchy in the following manner:
Course 1
Course 2
Course 3
Course 4
1. the question is how can i attach my result (in JSON) to populate the treeview?
2. After clicking on each course i also want to populate the course details (like subject1, subject 2....) "on demand". How should i do it?
Thanks in advance.
I am trying to populate the treeview by making an Ajax call. I am getting the following hierarchy in the following manner:
Course 1
Course 2
Course 3
Course 4
1. the question is how can i attach my result (in JSON) to populate the treeview?
2. After clicking on each course i also want to populate the course details (like subject1, subject 2....) "on demand". How should i do it?
Thanks in advance.
| <script type="text/javascript"> |
| function onLoad(e) { |
| var item = $('.t-item:first', $(e.target)); |
| var treeview = e.data; |
| /*-------Ajax call---------*/ |
| $.ajax({ |
| url: '/Resource/GetJSONCourses', |
| contentType: 'application/json; charset=utf-8', |
| type: 'GET', |
| dataType: 'json', |
| error: function(xhr, status) { |
| debugger; |
| alert(status); |
| }, |
| data: { |
| q: 'TEST-Subject' |
| }, |
| success: function(result) { |
| debugger; |
| treeview.dataBind(item, result); |
| //I AM CURRENTLY STUCK HERE |
| } |
| }); |
| /*-------Ajax call---------*/ |
| } |
| </script> |
| <p> |
| <% Html.Telerik().TreeView() |
| .Name("StdTree") |
| .ClientEvents(events => events |
| .OnLoad("onLoad") |
| ) |
| .Render(); |
| %> |
| </p> |
| <!-- CONTROLLER CODE --> |
| public ActionResult GetJSONCourses() |
| { |
| var Courses = from c in courses |
| select c; |
| return JsonResult(Courses); |
| } |
| public ActionResult GetJSONCourseDetails(string courseID) |
| { |
| var subjects = from c in subjects |
| where c.CourseID = courseID |
| select c; |
| return JsonResult(subjects); |
| } |
