2 hlz2013 hlz2013 于 2015.06.08 09:11 提问

在三层加.net mvc4.0 中使用ztree显示分类时为什么得到的显示效果是undefined

我Controller中的代码如下:
public ActionResult LoadAllCat()
{
List list = null;
list = new List();
List lists = categoryService.GetCategory();
foreach (var listcat in lists)
{
Category category = new Category();
category.Id = listcat.Id;
category.ParentsId = listcat.ParentsId;
category.CategoryName = listcat.CategoryName;
list.Add(category);
}
//JavaScriptSerializer jss = new JavaScriptSerializer();
//string ResultDt = jss.Serialize(list);
//return ResultDt;
return Json(list, JsonRequestBehavior.AllowGet);
}
Index.cshtml代码如下:
var setting = {
check: {
enable: true
},
//chkboxType: { "Y": "ps", "N": "ps" },//默认这个
data: {
simpleData: {
enable: true,
idKey: "Id", // id编号命名
pIdKey: "ParentsId", // 父id编号命名
rootPId: 0
}
},
async: {
enable: true,
contentType: "application/json",
dataType: "text",
url: "/CategoryList/LoadAllCat",
type:"GET",
autoParam: ["Id", "CategoryName","ParentsId"]
}
};
function checkNode(e) {
var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
type = e.data.type,
nodes = zTree.getSelectedNodes();
if (type.indexOf("All") < 0 && nodes.length == 0) {
alert("请先选择一个节点");
}
if (type == "checkAllTrue") {
zTree.checkAllNodes(true);
} else if (type == "checkAllFalse") {
zTree.checkAllNodes(false);
}
}
$(document).ready(function () {
$.fn.zTree.init($("#treeDemo"), setting);
$("#checkAllTrue").bind("click", { type: "checkAllTrue" }, checkNode);
$("#checkAllFalse").bind("click", { type: "checkAllFalse" }, checkNode);
});
//-->

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!