添加项目文件。
This commit is contained in:
47
HT.Cloud.Code/Web/Tree/TreeSelect.cs
Normal file
47
HT.Cloud.Code/Web/Tree/TreeSelect.cs
Normal file
@ -0,0 +1,47 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2016 HT.Cloud.Framework 版权所有
|
||||
* Author: HT.Cloud
|
||||
* Description: WaterCloud快速开发平台
|
||||
* Website:
|
||||
*********************************************************************************/
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace HT.Cloud.Code
|
||||
{
|
||||
public static class TreeSelect
|
||||
{
|
||||
public static string TreeSelectJson(this List<TreeSelectModel> data)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("[");
|
||||
sb.Append(TreeSelectJson(data, "0", ""));
|
||||
sb.Append("]");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
private static string TreeSelectJson(List<TreeSelectModel> data, string parentId, string blank)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
var ChildNodeList = data.FindAll(t => t.parentId == parentId);
|
||||
var tabline = "";
|
||||
if (parentId != "0")
|
||||
{
|
||||
tabline = " ";
|
||||
}
|
||||
if (ChildNodeList.Count > 0)
|
||||
{
|
||||
tabline = tabline + blank;
|
||||
}
|
||||
foreach (TreeSelectModel entity in ChildNodeList)
|
||||
{
|
||||
entity.text = tabline + entity.text;
|
||||
string strJson = entity.ToJson();
|
||||
sb.Append(strJson);
|
||||
sb.Append(TreeSelectJson(data, entity.id, tabline));
|
||||
}
|
||||
return sb.ToString().Replace("}{", "},{");
|
||||
}
|
||||
}
|
||||
}
|
18
HT.Cloud.Code/Web/Tree/TreeSelectModel.cs
Normal file
18
HT.Cloud.Code/Web/Tree/TreeSelectModel.cs
Normal file
@ -0,0 +1,18 @@
|
||||
/*******************************************************************************
|
||||
* Copyright © 2016 HT.Cloud.Framework 版权所有
|
||||
* Author: HT.Cloud
|
||||
* Description: WaterCloud快速开发平台
|
||||
* Website:
|
||||
*********************************************************************************/
|
||||
|
||||
namespace HT.Cloud.Code
|
||||
{
|
||||
public class TreeSelectModel
|
||||
{
|
||||
public string id { get; set; }
|
||||
public string text { get; set; }
|
||||
public string code { get; set; }
|
||||
public string parentId { get; set; }
|
||||
public object data { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user