Jquery easyui Tree的简单使用
Jquery easyui Tree的简单使用 Jquery easyui 是jQuery EasyUI是一组基于jQuery的UI插件集合,而jQuery EasyUI的目标就是帮助web开发者更轻松的打造出功能丰富并且美观的UI界面。开发者不需要编写复杂的javascript,也不需要对css样式有深入的了解,开发者需要了解的只有一些简单的html标签。 Jquery easyui 官网:http://jeasyui.com/ ,中文网站:http://www.jeasyui.net/,jquery easyui 下载地址:http://jeasyui.com/download/index.php ????在项目中有时需要页面设计,不巧美工前端人员比较忙或者其他原因,造成敲代码的程序猿不得不进行ui设计,此时可以尝试easyui。 进入正题,本文分两部分介绍easyui中tree的使用: 首先我们需要引用两个文件一个是 主题样式css文件,一个是easyui核心js文件(easyui依赖jquery,如果没有引用,需要添加引用) 在想要生成tree的ul加上class "easyui-tree" ? 1.静态数据Tree,结构确定,数据是确定的,数据直接在html写死的 2.动态数据Tree,结构不确定,动态数据,数据需要从服务器端获取 ?
经过使用 Fiddle调试可以发现每次请求时,请求参数为“id”,值为选择节点的id ? 服务器端处理程序getTypesNodeHandler.ashx示例代码: 移除tree当前选择项,当选中tree的某个?节点时,对应节点会多一个class为“tree-node-selected ”的样式,将这个样式去掉就可以移除选择的tree的选项 $(".tree-node-selected").removeClass("tree-node-selected"); ? 1 using System; 2 3 namespace Models.FormatModel 4 { 5 public TreeModel 6 { 7 //节点id 8 int id { get; set; } 9 10 节点显示的文本 11 string text { 12 13 open 、closed 14 string state { get { return "closed"; } } 15 } 16 } 2 System.Collections.Generic; System.Linq; System.Web; 5 WebApplication1.Handlers 7 8 /// <summary> 9 /// Summary description for getTypesNodeHandler 10 </summary> 11 getTypesNodeHandler : IHttpHandler 12 13 void ProcessRequest(HttpContext context) { 16 context.Response.ContentType = text/plain; 17 int parentId = 018 int.TryParse(context.Request[id"],out parentId); 19 List<Models.Category> types = null20 try 21 { 22 判断父节点的值 23 if (parentId > ) 24 { 25 加载子级菜单 26 types = CommonNews.Helper.OperateContext.Current.LoadSecondaryCategory(parentId); 27 } 28 else 29 30 加载顶级菜单 31 types = CommonNews.Helper.OperateContext.Current.LoadTopCategory(); 32 33 判断是否有值,有值的话先转换为tree模型再转换为json输出,没有值直接输出空字符串 34 if (types != 35 36 转换为tree模型 37 List<Models.FormatModel.TreeModel> tree = types.Select(t => new Models.FormatModel.TreeModel() { id = t.CategoryId,text = t.CategoryName }).ToList(); 38 转换为json格式数据输出 39 context.Response.Write(Common.ConverterHelper.ObjectToJson(tree)); 40 41 42 43 context.Response.Write(""); 44 45 } 46 catch (Exception ex) 47 48 new Common.LogHelper(typeof(getTypesNodeHandler)).Error(ex); 49 context.Response.Write(error50 51 } 52 53 bool IsReusable 54 55 get 56 57 return true58 59 60 61 } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – 如何在代码后面访问span id
- asp.net – 什么时候调用Application_End,我该如何手动导致
- asp.net – 为会话设置文化
- ide – 我如何处理必须编写经典ASP的代码?
- asp.net – WCF服务问题 – 不支持协议“http”.怎么解决?
- asp.net-mvc-4 – 使用KNOCKOUT.JS和ASP.NET MVC 4进行级联
- asp.net-mvc – 纯粹的DDD方法可以和NHibernate一起使用吗?
- asp.net – 在网页中显示OLAP SQL Server?
- Asp.Net MVC5代码的筛选器(ActionFilter)执行递归链表分析
- asp.net – 在标题后添加Gridview行