如何通过json转化数据生成Jquery easyui的树
1个回答
展开全部
在Controller里
/// <summary>
/// 服务树
/// </summary>
/// <returns></returns>
public ActionResult ServiceTree()
{
List<Service> Services = bll.GetModelList("CompanyID=" + CONST.TopCompanyID);
ViewData["Services"] = Services;
return View();
}
界面:
<div class="dtree">
<script type="text/javascript">
d = new dTree('d');
d.add("0", "-1", '全部服务');
<%
foreach (var item in (IEnumerable<mry.Model.Service>)ViewData["Services"])
{
if(item.Pid==null)item.Pid=0;
%>
d.add('<%:item.ID %>', '<%:item.Pid %>', '<%:item.Name %>', "javascript:dTreeOnClick('<%:item.ID %>','<%:item.IsDir%>')");
<% }%>
document.write(d);
d.openAll();
d.config.useCookies = false;
</script>
</div>
/// <summary>
/// 服务树
/// </summary>
/// <returns></returns>
public ActionResult ServiceTree()
{
List<Service> Services = bll.GetModelList("CompanyID=" + CONST.TopCompanyID);
ViewData["Services"] = Services;
return View();
}
界面:
<div class="dtree">
<script type="text/javascript">
d = new dTree('d');
d.add("0", "-1", '全部服务');
<%
foreach (var item in (IEnumerable<mry.Model.Service>)ViewData["Services"])
{
if(item.Pid==null)item.Pid=0;
%>
d.add('<%:item.ID %>', '<%:item.Pid %>', '<%:item.Name %>', "javascript:dTreeOnClick('<%:item.ID %>','<%:item.IsDir%>')");
<% }%>
document.write(d);
d.openAll();
d.config.useCookies = false;
</script>
</div>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询