当前位置: 首页 > 图文教程 > 网络编程 > Javascript > Expandable "Detail" Table Rows

Javascript
java编程教程:JDBC技术简介
浅析Ajax为什么优于JSF
JDK5.0中collection都有哪些变化
对性能和可扩展产生深远影响的J2EE
HTTP消息头字段深入介绍
java教程:网站开发中的入侵问题检测
简要介绍实现多线程环形缓冲的方法
DOM文档如何与XML文件互换?
Java教程:如何实现FTP功能
Bing API的简单了解
Javascript对网页输入框的字数限制
建立支持移动设备访问的网站sitemap
window.onload和body onload
JS教程:window.event对象
网页漂浮广告的关闭的实现代码
JavaScript教程:网页浮动定位提示效果
常用的Javascript代码高亮脚本
滑动导航菜单的变体使用
解决AJAX中文回传乱码
Javascript开发是否预留退路?

Javascript 中的 Expandable "Detail" Table Rows


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 130 ::
收藏到网摘: n/a

A common UI is to have a table of data rows, which when clicked on expand to show a detailed breakdown of "child" rows below the "parent" row.
The only requirements are:
Put a class of "parent" on each parent row (tr)
Give each parent row (tr) an id
Give each child row a class of "child-ID" where ID is the id of the parent tr that it belongs to
Example Code
$(function() {
$('tr.parent')
.css("cursor","pointer")
.attr("title","Click to expand/collapse")
.click(function(){
$(this).siblings('.child-'+this.id).toggle();
});
$('tr[@class^=child-]').hide().children('td');
});Example Table (click a row)

ID Name Total
123 Bill Gates 100
2007-01-02 A short description 15
2007-02-03 Another description 45
2007-03-04 More Stuff 40
456 Bill Brasky 50
2007-01-02 A short description 10
2007-02-03 Another description 20
2007-03-04 More Stuff 20
789 Phil Upspace 75
2007-01-02 A short description 33
2007-02-03 Another description 22
2007-03-04 More Stuff 20