首页 新闻 会员 周边 捐助

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

0
悬赏园豆:20 [待解决问题]

我Controller中的代码如下:

public ActionResult LoadAllCat()
{
List<Category> list = null;
list = new List<Category>();
List<Category> 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);
});
//-->
</script>

孤独侠的主页 孤独侠 | 初学一级 | 园豆:184
提问于:2015-06-08 08:18
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册