I am trying to bind data from json. In the controller, I am sending
......
public JsonResult LoadTree()
........
return Json(jn, JsonRequestBehavior.AllowGet);
In debug I get the values in jn (47 items, each has two enteries (text and value).
In the view, I am using the following script:
function onDataBinding(e) {
var url = 'CourseCases/LoadTree';
var result;
$.ajax({
url: url,
data: {},
contentType: "application/json",
success: function (data) {
alert(data);
var treeview = $("#TreeView").data("tTreeView");
treeview.bindTo(data);
}
});
}
It does not work, alert shows object, object; and the treeview is blank!
Any idea why? Thanks in advance.
Actually the properties that you are sending should be called
ValueandTextinstead ofvalueandtext. Here’s an example that works fine for me.Controller:
View (
~/Views/Home/Index.cshtml):