cs-SelectTree-DropTreeNode, SelectTreeList
ylbtech-Unitity: cs-SelectTree-DropTreeNode, SelectTreeList |
DropTreeNode.cs SelectTreeList.cs
1.A,效果图返回顶部 |
1.B,源代码返回顶部 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace Healthcare.Framework.Web.Mvc
{
public class DropTreeNode
{
public string RootValue { get; set; }
public string TreeNodeID { get; set; }
public string Text { get; set; }
public string Value { get; set; }
public string ParentTreeNodeID { get; set; } public string Css { get; set; }
} }
1.B.2,SelectTreeList.cs
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks; namespace Healthcare.Framework.Web.Mvc
{
/// <summary>
/// 树形下拉框
/// </summary>
public class SelectTreeList
{
#region 字段 List<DropTreeNode> treeNodes = new List<DropTreeNode>();
string rootValue = null;
string valueField = null;
string textField = null;
string nodeField = null;
string parentField = null; string css = null; string selectValue = ""; bool isFinalLevel = false; public bool IsFinalLevel
{
get { return isFinalLevel; }
set { isFinalLevel = value; }
} public string SelectValue
{
get { return selectValue; }
set { selectValue = value; }
} #endregion #region 构造函数 /// <summary>
/// 构造函数
/// </summary>
/// <param name="items">项集合</param>
/// <param name="rootValue">根元素字段</param>
/// <param name="textField">显示文本字段</param>
/// <param name="nodeField">节点字段</param>
/// <param name="parentField">父节点字段</param>
public SelectTreeList(IEnumerable items, string rootValue, string textField, string nodeField, string parentField)
{
this.rootValue = rootValue;
this.valueField = nodeField;
this.textField = textField;
this.nodeField = nodeField;
this.parentField = parentField;
Validate();
Init(items);
} /// <summary>
/// 构造函数
/// </summary>
/// <param name="items">项集合</param>
/// <param name="rootValue">根元素字段</param>
/// <param name="valueField">获取值字段</param>
/// <param name="textField">显示文本字段</param>
/// <param name="nodeField">节点字段</param>
/// <param name="parentField">父节点字段</param>
public SelectTreeList(IEnumerable items, string rootValue, string textField, string nodeField, string parentField, string valueField, string selectValue, bool isFinalLevel = false, string Css="")
{
this.rootValue = rootValue;
this.valueField = valueField;
this.textField = textField;
this.nodeField = nodeField;
this.parentField = parentField;
this.selectValue = selectValue;
this.isFinalLevel = isFinalLevel;
this.css = Css; Validate();
Init(items);
} #endregion /// <summary>
/// 验证各个参数的有效性
/// </summary>
public void Validate()
{
StringBuilder sb = new StringBuilder();
if (string.IsNullOrEmpty(valueField))
sb.AppendLine("获取值字段不能为空");
if (string.IsNullOrEmpty(textField))
sb.AppendLine("显示文本字段不能为空");
if (string.IsNullOrEmpty(nodeField))
sb.AppendLine("节点字段不能为空");
if (string.IsNullOrEmpty(parentField))
sb.AppendLine("父节点字段字段不能为空");
if (sb.Length > )
throw new Exception("验证错误:" + sb.ToString());
} /// <summary>
/// 初始化TreeNodes集合
/// </summary>
/// <param name="items"></param>
public void Init(IEnumerable items)
{
foreach (var item in items)
{
DropTreeNode treeNode = new DropTreeNode();
Type type = item.GetType(); PropertyInfo property = type.GetProperty(this.valueField);
object o = property.GetValue(item, null);
treeNode.Value = o.ToString(); property = type.GetProperty(this.textField);
o = property.GetValue(item, null);
treeNode.Text = o.ToString(); property = type.GetProperty(this.nodeField);
o = property.GetValue(item, null);
treeNode.TreeNodeID = o.ToString(); property = type.GetProperty(this.parentField);
o = property.GetValue(item, null);
treeNode.ParentTreeNodeID = o.ToString(); if (!string.IsNullOrEmpty(this.css))
{
property = type.GetProperty(this.css);
o = property.GetValue(item, null);
treeNode.Css = o.ToString();
}
else
treeNode.Css = ""; treeNodes.Add(treeNode);
}
} #region 字段属性 public List<DropTreeNode> TreeNodes
{
get { return treeNodes; }
set { treeNodes = value; }
} public string RootValue
{
get { return rootValue; }
set { rootValue = value; }
} public string ValueField
{
get { return valueField; }
set { valueField = value; }
} public string TextField
{
get { return textField; }
set { textField = value; }
} public string NodeField
{
get { return nodeField; }
set { nodeField = value; }
} public string ParentField
{
get { return parentField; }
set { parentField = value; }
} #endregion
} }
1.B.3,
1.C,下载地址返回顶部 |
![]() |
作者:ylbtech 出处:http://ylbtech.cnblogs.com/ 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。 |
cs-SelectTree-DropTreeNode, SelectTreeList的更多相关文章
- [C#] 剖析 AssemblyInfo.cs - 了解常用的特性 Attribute
剖析 AssemblyInfo.cs - 了解常用的特性 Attribute [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/5944391.html 序 ...
- Atitit 软件架构方法的进化与演进cs bs soa roa msa attilax总结
Atitit 软件架构方法的进化与演进cs bs soa roa msa attilax总结 1.1. 软件体系架构是沿着单机到 CS 架构,再到 BS 的三层架构甚至多层架构逐步发展过来的,关于 ...
- 从java文件和CS文件里查询方法使用次数工具
前几天,领导让我找一下老系统(Java)里getRemoteUser方法都哪个文件用了,package是什么,方法被调用了多少次,当时因为着急,所以,直接人工找的,但是以后要是再出现,人工找就太讨厌了 ...
- 关于 WP 开发中.xaml 与.xaml.cs 的关系
今天我们先来看一下在WP8.1开发中最长见到的几个文件之间的关系.比较论证,在看这个问题之前我们简单看看.NET平台其他两个不同的框架: Windows Forms 先看看Window Forms中的 ...
- .net 用户控件ascx.cs注册js脚本代码无效果
在.net web项目中碰到一个比较奇怪的问题,网上没找到解决方案,先自己mark一下 问题描述: 添加一个用户控件ascx,在后端.cs添加js注册脚本,执行后没有弹出框 注册脚本为: this.P ...
- DateHelper.cs日期时间操作辅助类C#
//==================================================================== //** Copyright © classbao.com ...
- 仅用aspx文件实现Ajax调用后台cs程序。(实例)
仅用aspx文件实现Ajax调用后台cs无刷新程序.(实例) 两个文件:aaa.aspx 和aaa.aspx.cs 一.aaa.aspx <script type="text/java ...
- Etw EventSourceProvider_EventsProducer.cs OopConsoleTraceEventListenerMonitor_TraceControllerEventsConsumer.cs
// EventSourceProvider_EventsProducer.cs /* /r:"D:\Microshaoft.Nuget.Packages\Microsoft.Diagnos ...
- WPF根据Oracle数据库的表,生成CS文件小工具
开发小工具的原因: 1.我们公司的开发是客户端用C#,服务端用Java,前后台在通讯交互的时候,会用到Oracle数据库的字段,因为服务器端有公司总经理开发的一个根据Oracle数据库的表生成的cla ...
随机推荐
- 常见的makefile写法【转】
转自:http://blog.csdn.net/ghostyu/article/details/7755177 版权声明:本文为博主原创文章,未经博主允许不得转载. .目标名称,摆脱手动设置目标名称 ...
- locust===官方说明文档,关于tasks
安装: >>> pip install locust locust在官方simple_code中如下: from locust import HttpLocust, TaskSet ...
- python基础===python3中 http.client 和 urllib的那些事
import http.client #python3中没有了 httplib的库 #python 3.x中urllib库和urilib2库合并成了urllib库.. #其中urllib2.urlop ...
- git应用基础配置
1.注册github账号.注册的时候会要求输入用户名和email这是配置git必须的要素 2.在使用git的时候首先需要把注册时候配合的用户名和密码填在git仓库的配置文件里,如下 harvey@ha ...
- lucene in action
1. 索引——好比字典的索引一样,进行查询时使用 2. Field.Index.NO 则没有索引,则不能被搜索 3. 第三章 PhraseQuery 短语查询 按照顺序添加term PharseQu ...
- python-函数(装饰器)
装饰器 装饰器的主要功能: 在不改变函数调用方式的基础上在函数的前.后添加功能. 装饰器的固定格式: #装饰器的本质 :闭包函数 #功能:就是在不改变原函数调用方式的情况下,在这个函数前后加上扩展功能 ...
- 只有5行代码的算法——Floyd算法
Floyd算法用于求一个带权有向图(Wighted Directed Graph)的任意两点距离的算法,运用了动态规划的思想,算法的时间复杂度为O(n^3).具体方法是:设点i到点j的距离为d[i][ ...
- 洛谷 P1012 拼数 [字符串]
题目描述 设有n个正整数(n≤20),将它们联接成一排,组成一个最大的多位整数. 例如:n=3时,3个整数13,312,343联接成的最大整数为:34331213 又如:n=4时,4个整数7,13,4 ...
- HDU 5935 Car【贪心,枚举,精度】
Problem Description Ruins is driving a car to participating in a programming contest. As on a very t ...
- 2017中国大学生程序设计竞赛 - 女生专场B【DP】
B HDU - 6024 [题意]:n个教室,选一些教室建造糖果商店. 每个教室,有一个坐标xi和在这个教室建造糖果商店的花费ci. 对于每一个教室,如果这个教室建造糖果商店,花费就是ci,否则就是与 ...