#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的更多相关文章

  1. [转]easyui tree 模仿ztree 使用扁平化加载json

    原文地址:http://my.oschina.net/acitiviti/blog/349377 参考文章:http://www.jeasyuicn.com/demo/treeloadfilter.h ...

  2. 数据网格和树-EasyUI Datagrid 数据网格、EasyUI Propertygrid 属性网格、EasyUI Tree 树、EasyUI Treegrid 树形网格

    EasyUI Datagrid 数据网格 扩展自 $.fn.panel.defaults.通过 $.fn.datagrid.defaults 重写默认的 defaults. 数据网格(datagrid ...

  3. jquery easyui tree dialog

    <script type="text/javascript" src="<%=request.getContextPath()%>/include/ja ...

  4. 【项目经验】EasyUI Tree

    ITOO5.0开始了,我参加了伟大的基础系统,从整体上来说,基础系统有三个职能: 1.自己的核心职能--选课(公共选修课,专业选修课),课表: 2.为其他系统提供真实数据: 3.维护信息 而近两三天, ...

  5. EasyUI tree 异步树与采用扁平化实现的同步树

    所谓好记性不如烂笔头,为了以防忘记,才写下这篇博客,废话不多.. 异步树: tips:   可以采用easyui里的原始数据格式,也可以采用扁平化的数据格式. 使用场景: 当菜单模块数量庞大或者无限极 ...

  6. Easyui Tree方法扩展 - getLevel(获取节点级别)

    Easyui Tree一直就没有提供这个方法,以前没有用到,所以一直没怎么在意,这次自己用到了,顺便扩展了一个方法,分享给大家. $.extend($.fn.tree.methods, { getLe ...

  7. Jquery EasyUI Tree .net实例

    图片: 针对tree: 数据库: CREATE TABLE [dbo].[SystemModel]( [Id] [,) NOT NULL, [Name] [nvarchar]() NULL, [Fat ...

  8. Jquery easyui Tree的简单使用

    Jquery easyui Tree的简单使用 Jquery easyui 是jQuery EasyUI是一组基于jQuery的UI插件集合,而jQuery EasyUI的目标就是帮助web开发者更轻 ...

  9. Jquery easyui tree的使用

    这个ui用的一切都是json数据.树也是如此! 后台需要返回与格式匹配的json数据才能正确加载树. 页面定义一个ui: <ul id="messageInfoAddTree" ...

随机推荐

  1. git 的 基础操作及使用

    /* git svn版本控制器 */ /*git把文件对应的储存空间分为三个区: 1.工作区 2.缓存区 3.历史区 直接操作文件,不做add时,咱们是在工作区做的修改 右键 git bash her ...

  2. acm相关(纯转载)

    我觉得很好的文章,之所以放随笔是为了让大家看到这些优秀的博文 acm如何起步 acm重点题型 动态规划题目总结 背包九讲阅读网站

  3. Number Theory Problem(The 2016 ACM-ICPC Asia China-Final Contest 找规律)

    题目: Mr. Panda is one of the top specialists on number theory all over the world. Now Mr. Panda is in ...

  4. Scoop - 在Windows命令行上进行程序安装

    2019-01-28  22:49:21 资料来源自Scoop官方网站以及github上的帮助文档 如果有疑惑或者觉得文章有错误请留言以帮助改正 补充内容(2019-04-09 21:11:36):不 ...

  5. Python数据分析与展示(1)-数据分析之表示(2)-NumPy数据存取与函数

    NumPy数据存取与函数 数据的CSV文件存取 CSV文件 CSV(Comma-Separated Value,逗号分隔值) CSV是一种常见的文件格式,用来存储批量数据. 将数据写入CSV文件 np ...

  6. intel compiler的表现

    好久没弄这个东西,今天突然想试下,代码没写完,以后补. #include <stdio.h> #include <stdlib.h> #include <time.h&g ...

  7. POJ - 2007 极角排序(Java 实现)

    POJ 2007 将所有的点按逆时针输出 import java.io.*; import java.util.*; public class Main { static class Point im ...

  8. 【Codeforces 279C】Ladder

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 设pre[i]表示i往前一直递增能递增多远 设aft[i]表示i往后一直递增能递增多远 如果aft[l]+pre[r]>=(r-l+1) ...

  9. Linux 安装 RabbitMQ

    转载文章,地址:https://www.cnblogs.com/uptothesky/p/6094357.html 侵删!

  10. [A]System.Web.WebPages.Razor.Configuration.HostSection 无法强制转换为 [B]System.Web.WebPages.Razor.Configuration.HostSection。

    记录下mvc4升级到mvc5后,运行项目提示: “/”应用程序中的服务器错误. [A]System.Web.WebPages.Razor.Configuration.HostSection 无法强制转 ...