当我点击 末端子节点,又把整个树给加载一遍(在程序里边设置断点,又执行了一遍),加载到末端子节点,怎么样才能避免?谢谢!!
@{
ViewBag.Title = "我看过的";
Layout = "~/Views/Shared/_Admin.cshtml";
}@section Header{
<link rel="stylesheet" type="text/css" href="/Scripts/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/Scripts/easyui/themes/icon.css">
<script type="text/javascript" src="/Scripts/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function () {
LoadTree();
});
function LoadTree() {
$('#tree').tree({
checkbox: true,
lines:true,
url: '/UserManage/GetTreeViewData'
});
}
</script>
}
<h1 class="title">
我看过的</h1> <div region="west" split="true" title="影视分类" style="width:200px;padding:10px;">
<ul id="tree"></ul>
</div>action public JsonResult GetTreeViewData()
{
return Json(RegisteredUserBLL.GetUserTree());
}
bll public static List<TreeView> GetUserTree()
{
using (var db = new WEBVODEntities())
{
var list = db.RegisteredUsers.Include("Department").OrderBy(a => a.Department.Name)
.ThenBy(a => a.RealName).ToList();
int deptId = 0;
List<TreeView> treeList = new List<TreeView>();
TreeView treeRoot = new TreeView(0,"全员职工","open",null);
TreeView treeDept = null;
TreeView treeUser = null; treeList.Add(treeRoot);
if (list.Count > 0)
treeRoot.children = new List<TreeView>(); foreach (RegisteredUsers user in list)
{ if (user.DepartmentId != deptId)
{
deptId = (int)user.DepartmentId;
treeDept = new TreeView(-(int)user.DepartmentId, user.Department.Name, "closed", new List<TreeView>());
treeRoot.children.Add(treeDept); treeUser = new TreeView(user.Id, user.RealName, "closed", null);
treeDept.children.Add(treeUser);
}
else
{
treeUser = new TreeView(user.Id, user.RealName, "closed", null);
treeDept.children.Add(treeUser);
}
} return treeList; }
}
treeUser = new TreeView(user.Id, user.RealName, "open", null, null);不过还是希望得使用过的给点建议还有就是我的tree表示的是机构里边的人员,默认的图标没有,如果您有,请给一份