t28利用jquery.treeview插件实现树状导航_第1页
t28利用jquery.treeview插件实现树状导航_第2页
t28利用jquery.treeview插件实现树状导航_第3页
t28利用jquery.treeview插件实现树状导航_第4页
t28利用jquery.treeview插件实现树状导航_第5页
免费预览已结束,剩余15页可下载查看

付费下载

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、北风网项目培训第28讲:利用jQuery.TreeView插件实现树状导航讲师:风舞烟JavaScript-JQuery系列全程精通+图书馆管理系统实战目录jQuery.TreeView插件简介jQuery.TreeView插件使用Query.TreeView异步jQuery.TreeView插件简介该插件的特点:1、支持静态的树,即一次性将全部数据加载到客户端。2、支持异步树,即一次只加载一级或若干级节点,子节点可以异步加载数据。3、支持节点级联。4、能够承载大数据量,并性能表现优异。5、支持主流浏览器。 6、使用方便官方网站: jQuery.TreeView插件使用使用jQuery.Tre

2、eViewStep 1:添加相关css及js的引用Simple:页面文件.htmlItem 1Item 1.0Item 1.0.0Item 1.1JS代码 $(document).ready(function() $(#navigation).treeview( persist: cookie, collapsed: true, unique: true ); );效果:treeview(options ) Options说明:1、animated设置动画效果.Eg:$(.selector).treeview( animated: fast ) 2、collapsed Treeview节点是否

3、收缩,true:收缩,false:展开$(.selector).treeview( collapsed: true ) 3、control TreeView显示的容器$(.selector).treeview( control: “#container” ) 4、unique 设置是否某一时刻只展开一个节点,true:只展开一个,false:可以同时展开其他节点。$(.selector).treeview( unique: true ) 5、toggle Note: Callback when toggling a branch. Arguments: this refers to the U

4、L that was shown or hidden. Works only with speed option set (set speed: 1 to enable callback without animations). 。$(.selector).treeview( toggle: function() console.log(this + has been toggled); ) 6、persist Note: Persist the tree state in cookies or the page location. If set to location, looks for

5、the anchor that matches location.href and activates that part of the treeview it. Great for href-based state-saving. If set to cookie, saves the state of the tree on each click to a cookie and restores that state on page load. $(.selector).treeview( persist: location ) 8、addEg:Creates a treeview and

6、 adds more elements to it on button-click. var tree = $(.selector).treeview(); $(.button).click(function() var newSublist = $(New Sublist + Item1 + Item2).appendTo(tree); tree.treeview( add: newSublist ); ); 9、异步树的加载 jquery.treeview.async用于在页面显示一个树形菜单,其特点在于所有节点都是异步获取的(只加载所需的节点,避免一次性加载全部导致客户端浏览器卡死),服

7、务器端返回json格式的对象数组即可。每个json对象可以包含如下属性:说明:异步获取节点数据时,treeview会使用get方式提交一个参数(root)到服务器端,treeview初始化(首次加载)时,这个参数值为source,之后异步获取子节点时,参数值为所点击节点的id值,服务器端需根据这一参数值不同返回不同的json对象数组:Step1:添加jquery.treeview.async.js的引用Step2:前台HTMLMain DemoServer component usedLazy-loading treeStep3:前台JS$(document).ready(function()

8、$(#black).treeview( url: source.aspx);Step4:后台source.aspx protected void Page_Load(object sender, EventArgs e) /代表首次加载 if (Requestroot != null & Requestroot.ToString() = source) Response.Write( + text:根节点1,id:root1,hasChildren:true,text:根节点2,id:root2,hasChildren:true + ); else if (Requestroot != nul

9、l) /说明点击的是root1 string id = Requestroot.ToString(); if (id=root1) Response.Write(text:根节点1-子节点1,id:root1-child1,text:根节点1-子节点2,id:root1-child2); else if (id=root2) Response.Write(text:根节点2-子节点1,id:root2-child1,text:根节点2-子节点2,id:root2-child2); jQuery.treeview.async.plug.js扩展插件利用此插件可以让后台返回的json数据,多两个属性,url,target.形如:text:根节点1-子节点1,ur

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论