1
json과 함께 jsTree를 서버의 데이터 소스로 사용하고 있습니다.jsTree는 모든 부모 확장을위한 Ajax 요청을 수행합니다.
노드를 클릭 할 때마다 jsTree가 요청하는 이유는 무엇이며 노드에 자식이 없더라도 노드는 서버의 자식으로 채워집니다 (루트 데이터를 사용합니다!).
어떻게 그 행동을 막을 수 있습니까?
json과 함께 jsTree를 서버의 데이터 소스로 사용하고 있습니다.jsTree는 모든 부모 확장을위한 Ajax 요청을 수행합니다.
노드를 클릭 할 때마다 jsTree가 요청하는 이유는 무엇이며 노드에 자식이 없더라도 노드는 서버의 자식으로 채워집니다 (루트 데이터를 사용합니다!).
어떻게 그 행동을 막을 수 있습니까?
스크립트
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$(function() {
$("#treeview").jstree({
"json_data": {
"ajax": {
"url": "/Tree/Tree"
}
},
"plugins": ["themes", "json_data"]
});
});
});
</script>
서버 측 :
public class TreeController : Controller
{
//
// GET: /Tree/
public ActionResult Tree()
{
return Json(new jsTreeModel
{
data = "Parent",
att = new JsTreeAttribute { id = 1 },
state = "closed",
children = new List<jsTreeModel> { new jsTreeModel { data = "Child", att = new JsTreeAttribute { id = 1 }, state = "closed" } }
}, JsonRequestBehavior.AllowGet);
}
}
public class jsTreeModel
{
public string data { get; set; }
public JsTreeAttribute att { get; set; }
public string state { get; set; }
public List<jsTreeModel> children { get; set; }
}
public class JsTreeAttribute
{
public int id { get; set; }
}