ASP.NET框架获取数据字典数据做成树的格式
private List<TreeEntity> treeList = new List<TreeEntity>();//创建一个树的List集合
public ActionResult GetTree1Json(string id)
{
var root = new DataItemBLL().GetEntity(id);//树的根节点
TreeEntity tree = new TreeEntity();//创建一个树的实体对象
tree.id = root.ItemId;//根节点树的ID
tree.text = root.ItemName;//根节点要在前端显示的内容
tree.value = root.ItemCode;//根节点的值
tree.isexpand = true;//是否需要展开
tree.complete = true;
tree.hasChildren = true;//是否还有子节点
tree.parentId = "0";//根节点的父ID必须为0才会显示
treeList.Add(tree);//把树放到树的List集合里面去
set(id);
void set(string ia) {//以此类推
var datalist = messagesendbll.GetDataList(ia);
foreach (DataItemEntity die in datalist)
{
tree = new TreeEntity();
tree.id = die.ItemId;
tree.text = die.ItemName;
tree.showcheck = true;
tree.isexpand = false;
tree.complete = true;
tree.hasChildren = true;
tree.parentId = die.ParentId;
treeList.Add(tree);
var de4 = messagesendbll.GetDataItemList(die.ItemId);
foreach (DataItemDetailEntity dde in de4)
{
TreeEntity tree4 = new TreeEntity();
tree4.id = dde.ItemDetailId;
tree4.text = dde.ItemName;
tree4.value = dde.ItemCode;
tree4.Attribute = "score";
tree.AttributeValue = dde.ItemCode;
tree4.showcheck = true;
tree4.isexpand = false;
tree4.complete = true;
tree4.parentId = dde.ItemId;
treeList.Add(tree4);
}
set(die.ItemId);
} }
return Content(treeList.TreeToJson()); }
前端js代码:
//初始化数据
function initControl() {
var item = {
showcheck: true,
url: "../../SPManage/SP_WConsult/GetTree1Json",
}; $("div").treeview(item);
}
ASP.NET框架获取数据字典数据做成树的格式的更多相关文章
- 用$.getJSON() 和$.post()获取第三方数据做页面 ——惠品折页面(1)
用$.getJSON() 和$.post()获取第三方数据做页面 首页 index.html 页面 需要jquery 和 template-web js文件 可以直接在官网下载 中间导航条的固 ...
- js中把ajax获取的数据转化成树状结构(并做成多级联动效果)
1.首先通过ajax获取数据,此处省略,直接贴出获取到的数据格式 var arr = [{ id: 1, name: "一级标题", pid: 0 }, { id: 2, name ...
- 【CSS系列】获取实时数据做进度
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 在ssm框架中前后台数据交互均使用json格式
前后台数据交互均使用json. 框架ssm(spring+springmvc+mybatis) @RequestBody注解实现接收http请求的json数据,将json数据转换为java对象,注解加 ...
- Golang 网络爬虫框架gocolly/colly 五 获取动态数据
Golang 网络爬虫框架gocolly/colly 五 获取动态数据 gcocolly+goquery可以非常好地抓取HTML页面中的数据,但碰到页面是由Javascript动态生成时,用goque ...
- asp.net三层架构 及其中使用泛型获取实体数据介绍
asp.net中使用泛型获取实体数据可以发挥更高的效率,代码简洁方便,本例采用三层架构.首先在model层中定义StuInfo实体,然后在 DAL层的SQLHelper数据操作类中定义list< ...
- Thinkphp3.2.3框架下封装公共的函数,例如封装CURL函数来获取接口数据
当我们需要在控制层调用相同的封装函数时,写多次相同的函数,显得代码十分的拉杂,不精简: TP框架有一个很好的机制,可以再Common定义一个function.php函数,当我们在控制层调用的时候直接调 ...
- 利用AddressBook.framework框架获取iOS系统通讯录数据
此方法是使用AddressBook.framework框架获取通讯录信息 第一步.在info.plist文件里面配置访问权限 第二步.导入头文件 #import <AddressBook/Add ...
- Yii2框架查询指定字段和获取添加数据的id
指定字段: $historyinfo = Healthy::find()->select(['healthy_id','pet_name','hardware_name','hardware_c ...
随机推荐
- SQL TINYINT 1 讨论记录
SQL TINYINT 1 讨论记录 群里有一位小伙伴又和他上司怒上了,关于 TINYINT 1 的问题. 这里记录一下,TINYINT 无符号可以是 0~255,而这里的 长度 1只是长度,并不是存 ...
- 获取DOS命令的返回值.
procedure CheckResult(b: Boolean); begin if not b then raise Exception.Create(SysErrorMessage(GetLas ...
- optimize table tablename
optimize 优化表OPTIMIZE 命令支持的引擎MyIsam, InnoDB, ARCHVE当对表有大量的增删改操作时,需要用optimize对表进行优化,可以减少空间与提高I/O性能,命令o ...
- yii console
Here is a step by step to show how to run command in the server with yii framework. 1. Create the we ...
- Java-Maven-Runoob:Maven 插件
ylbtech-Java-Maven-Runoob:Maven 插件 1.返回顶部 1. Maven 插件 Maven 有以下三个标准的生命周期: clean:项目清理的处理 default(或 bu ...
- AngularJS:控制器
ylbtech-AngularJS:控制器 1.返回顶部 1. AngularJS 控制器 AngularJS 控制器 控制 AngularJS 应用程序的数据. AngularJS 控制器是常规的 ...
- C#简单操作app.config文件
即将操作的app.config文件内容如下 <?xml version="1.0" encoding="utf-8"?> <configura ...
- 执行make出现“Warning: File `xxx.c' has modification time 2.6e+04 s in the future“警告的解决方法
错误描述: 执行make命令时出现"make[2]: Warning: File `xxx.c' has modification time 1.6e+05 s in the future ...
- WebSocket实战之JavaScript例子
一.详细代码案例 详细解读一个简单html5 WebSocket的Js实例教程,附带完整的javascript websocket实例源码,以及实例代码效果演示页面,并对本实例的核心代码进行了深入解读 ...
- 「小程序JAVA实战」微信小程序工程结构了解(五)
转自:https://idig8.com/2018/08/09/xiaochengxu-chuji-05/ 微信小程序工程结构 audio,button,canvas,checkbox 都是由4个文件 ...