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

Javascript
JGrid中拖动改变列宽的脚本 原型
javascript 兼容FF的onmouseenter和onmouseleave的代码
js树形控件脚本代码
javascript+xml技术实现分页浏览
js可拖动的后台界面
javascript 单选框,多选框美化代码
javascript之可拖动的iframe效果代码
js 文本框里粘贴一个图片url并显示
JavaScript国旗变换效果代码
jquery之Document元素选择器篇
开发跨浏览器的JavaScript方法说明
javascript过滤危险脚本方法
JQUERY THICKBOX弹出层插件
IE浏览器PNG图片透明效果代码
多浏览器兼容的动态加载 JavaScript 与 CSS
javascript实现的仿腾讯QQ窗口抖动效果代码
SyntaxHighlighter代码加色使用方法
用JavaScrpt实现文件夹简单轻松加密的实现方法图文
利用Ext Js生成动态树实例代码
javascript批量检查当图片不存在时则显示默认图片的代码

Javascript 中的 Expandable "Detail" Table Rows


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-10-12   浏览: 85 ::
收藏到网摘: 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