适用于zTree 、EasyUI tree、EasyUI treegrid
#region
System.Text.StringBuilder b_appline = new System.Text.StringBuilder();
System.Text.StringBuilder b_children = new System.Text.StringBuilder();
/// <summary>
/// 适用于zTree 、EasyUI tree、EasyUI treegrid
/// zTree设置id,name,EastyUI 设置 id,text EasyUI treegrid 可自定义
/// </summary>
/// <param name="Source">数据源</param>
/// <param name="_parentidName">父级名称</param>
/// <param name="_parentidValue">父级顶级节点</param>
/// <param name="Key">子节点(唯一值)</param>
/// <returns></returns>
public string GetTreeJson(DataTable Source, string _parentidName, string _parentidValue, string Key)
{
try
{
b_appline.Append(b_children.ToString());
b_children.Clear();
if (Source.Rows.Count > 0)
{
b_children.Append("[");
DataRow[] row = Source.Select(string.Format("{0}='{1}'", _parentidName, _parentidValue));
if (row.Count() > 0)
{
for (int i = 0; i < row.Count(); i++)
{
b_children.Append("{");
for (int c = 0; c < Source.Columns.Count; c++)
{
b_children.AppendFormat("\"{0}\":\"{1}\",", Source.Columns[c].ColumnName, row[i].ItemArray[c]);
}
b_children.Remove(b_children.Length - 1, 1);
if (Source.Select(string.Format("{0}='{1}'", _parentidName, row[i][Key].ToString())).Length > 0)
{
b_children.Append(",\"children\":");
GetTreeJson(Source, _parentidName,row[i][Key].ToString(), Key);
b_appline.Append(b_children.ToString());
b_children.Clear();
}
b_appline.Append(b_children.ToString());
b_children.Clear();
b_children.Append("},");
}
b_children.Remove(b_children.Length - 1, 1);
}
b_children.Append("]");
b_appline.Append(b_children.ToString());
b_children.Clear();
}
return b_appline.ToString();
}
catch (Exception)
{
throw;
}
}
#endregion
适用于zTree 、EasyUI tree、EasyUI treegrid的更多相关文章
- [转]easyui tree 模仿ztree 使用扁平化加载json
原文地址:http://my.oschina.net/acitiviti/blog/349377 参考文章:http://www.jeasyuicn.com/demo/treeloadfilter.h ...
- 数据网格和树-EasyUI Datagrid 数据网格、EasyUI Propertygrid 属性网格、EasyUI Tree 树、EasyUI Treegrid 树形网格
EasyUI Datagrid 数据网格 扩展自 $.fn.panel.defaults.通过 $.fn.datagrid.defaults 重写默认的 defaults. 数据网格(datagrid ...
- jquery easyui tree dialog
<script type="text/javascript" src="<%=request.getContextPath()%>/include/ja ...
- 【项目经验】EasyUI Tree
ITOO5.0开始了,我参加了伟大的基础系统,从整体上来说,基础系统有三个职能: 1.自己的核心职能--选课(公共选修课,专业选修课),课表: 2.为其他系统提供真实数据: 3.维护信息 而近两三天, ...
- EasyUI tree 异步树与采用扁平化实现的同步树
所谓好记性不如烂笔头,为了以防忘记,才写下这篇博客,废话不多.. 异步树: tips: 可以采用easyui里的原始数据格式,也可以采用扁平化的数据格式. 使用场景: 当菜单模块数量庞大或者无限极 ...
- Easyui Tree方法扩展 - getLevel(获取节点级别)
Easyui Tree一直就没有提供这个方法,以前没有用到,所以一直没怎么在意,这次自己用到了,顺便扩展了一个方法,分享给大家. $.extend($.fn.tree.methods, { getLe ...
- Jquery EasyUI Tree .net实例
图片: 针对tree: 数据库: CREATE TABLE [dbo].[SystemModel]( [Id] [,) NOT NULL, [Name] [nvarchar]() NULL, [Fat ...
- Jquery easyui Tree的简单使用
Jquery easyui Tree的简单使用 Jquery easyui 是jQuery EasyUI是一组基于jQuery的UI插件集合,而jQuery EasyUI的目标就是帮助web开发者更轻 ...
- Jquery easyui tree的使用
这个ui用的一切都是json数据.树也是如此! 后台需要返回与格式匹配的json数据才能正确加载树. 页面定义一个ui: <ul id="messageInfoAddTree" ...
随机推荐
- 一步一步实现基于GPU的pathtracer(三):path tracing 简述
全局光照这个名词在计算机图形学里已经不算一个新名词了,现在一提到拟真度,很多人基本上都会去想到全局光照,这个名词上世纪七八十年代就有了,好像是由一个叫Jim Kajiya的大神在他那篇已经被引用了不知 ...
- <MyBatis>入门一 HelloWorld
1.HelloWorld 导入依赖 <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis --> <dependen ...
- Swing之登录界面
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Login extends JFrame ...
- display math in cnblog
$a=b+c$ this is a example \(a=\frac{b}{c}\)
- change legend layout from 'vertical' to 'horizontal' in Paraview
********** # get color legend/bar for 'vLUT' in view 'renderView1'vLUTColorBar = GetScalarBar(vLUT, ...
- Intellij IDEA神器居然还有这些小技巧---超级好用的
Intellij IDEA神器居然还有这些小技巧----https://my.oschina.net/samgege/blog/1808622?p=8
- Oracle 关于几个随机函数sys_guid、dbms_random.random、dbms_random.value(取随机的结果集)
sys_guid():SYS_GUID (),是Oracle 8i 后提供的函数.SYS_GUID产生并返回一个全球唯一的标识符(原始值)由16个字节组成.更适合多个数据库数据集成时使用(--源自百度 ...
- poj 2823单调队列模板题
#include<stdio.h>//每次要吧生命值长的加入,吧生命用光的舍弃 #define N 1100000 int getmin[N],getmax[N],num[N],n,k, ...
- 对象和变量的并发访问synchronized解析以及死锁分析排查
一.synchronized java并发编程中存在“非线程安全"问题.“非线程安全"是指发生在多个线程对同一个对象中的实例变量并发访问时,产生的”脏读“现象,使用synchron ...
- Waiting For Debugger
在eclipse中进行调试时常常出现以下这种提示:Application (app名称) is waiting for the debugger to attach 正常情况下.会非常快进入应用调 ...