Jquery + Bootstrap 做的一个Expander Grid

代码:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="../bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="../bootstrap/css/bootstrap-responsive.min.css" />
<link href="../bootstrap/css/docs.css" rel="stylesheet">
<style type="text/css"><!--
	.table th,.table td{
		text-align: center;
	}
	.checkbox {
	    min-height: 15px;
	    padding-left: 30px;
	}
	.selected{
		background-color : #E5F9FF
	}
</style>

</head>
<body data-spy="scroll" data-target=".bs-docs-sidebar" style="background-position: 0 0px;padding:30px 0px 40px 0px;>
	<header class="">
		<div class="container">
			<div class="row">
				<div class="span4">
				</div>
				<div class="span8" style="text-align: right;">
					<h2>{Large School Test Suite Upgrade}</h2>
				</div>
			</div>
		</div>
	</header>
	<hr>
	<div class="container">
		<div class="row"><div class="span4"><h4>1. New templates in latest suite</h4></div></div>
	<table class="table table-bordered table-hover" style="cursor:pointer;">
		<thead>
			<th width="5%"><div class="icon-resize-full" id="newAllExpand"></div></th>
			<th width="5%"><label class="checkbox"><input type="checkbox" id="newAllCheck"></label></th>
			<th width="5%">#</th>
			<th width="48%">Role Name</th>
			<th width="48%">Crisis Name</th>
		</thead>
		<tbody id="newSuite">
			<tr>
				<td width="2%"><div class="icon-plus"></div></td>
				<td><label class="checkbox"><input type="checkbox" value=""></label></td>
				<td>1</td>
				<td>Row1</td>
				<td>Row1</td>
			</tr>
			<tr style="display:none;">
				<td colspan="5">
					<table width="80%" align="center" class="table-bordered">
					<caption class="text-error" ><strong>Checklists and Communication Message</strong></caption>
					<thead>
						<th width="5%">#</th><th width="65%">Step Name</td><th width="30%">Step Type</td>
					</thead>
					<tr>
						<td>1</td><td>asd s sa as ds ad s  sa</td><td>checkbox</td>
					</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td width="2%"><div class="icon-plus"></div></td>
				<td><label class="checkbox"><input type="checkbox" value=""></label></td>
				<td>2</td>
				<td>Row2</td>
				<td>Row2</td>
			</tr>
			<tr style="display:none;">
				<td colspan="5">adadsadas</td>
			</tr>
			<tr>
				<td width="2%"><div class="icon-plus"></div></td>
				<td><label class="checkbox"><input type="checkbox" value=""></label></td>
				<td>3</td>
				<td>Row3</td>
				<td>Row3</td>
			</tr>
			<tr style="display:none;">
				<td colspan="5">adadsadas</td>
			</tr>
		</tbody>
	</table>
	<div class="row"><div class="span5"><h4>2. Templates that are different form local templates</h4></div></div>
	<table class="table table-bordered table-hover" style="cursor:pointer;">
		<thead>
			<th width="5%"><div class="icon-resize-full" id="oldAllExpand"></div></th>
			<th width="5%"><label class="checkbox"><input type="checkbox" id="oldAllCheck"></label></th>
			<th width="5%">#</th>
			<th width="48%">Role Name</th>
			<th width="48%">Crisis Name</th>
		</thead>
		<tbody id="oldSuite">
			<tr>
				<td width="2%"><div class="icon-plus"></div></td>
				<td><label class="checkbox"><input type="checkbox" value=""></label></td>
				<td>1</td>
				<td>Row1</td>
				<td>Row1</td>
			</tr>
			<tr style="display:none;">
				<td colspan="5">adadsadas</td>
			</tr>
			<tr>
				<td width="2%"><div class="icon-plus"></div></td>
				<td><label class="checkbox"><input type="checkbox" value=""></label></td>
				<td>2</td>
				<td>Row2</td>
				<td>Row2</td>
			</tr>
			<tr style="display:none;">
				<td colspan="5">adadsadas</td>
			</tr>
			<tr>
				<td width="2%"><div class="icon-plus"></div></td>
				<td><label class="checkbox"><input type="checkbox" value=""></label></td>
				<td>3</td>
				<td>Row3</td>
				<td>Row3</td>
			</tr>
			<tr style="display:none;">
				<td colspan="5">adadsadas</td>
			</tr>
		</tbody>
	</table>
		<div><button class="btn btn-large btn-block btn-primary" type="button">UPGRADE SELECTED ITEMS</button></div>
	</div>
	<footer class="footer">
		<div class="container">
			<p style="text-align:center;">
				Designed and built with all the love in the world by <a
					href="http://www.edautomate.com" target="_blank">EdAutomate</a>.
			</p>
			<p style="text-align:center;">
				<a href="#">EdAutomate CrisisGo System V1.0</a>
			</p>
		</div>
	</footer>
	
<script style="text/javascript" src="../bootstrap/js/jquery-1.9.1.min.js"></script>
<script style="text/javascript" src="../bootstrap/js/bootstrap.min.js"></script>

<script type="text/javascript">
	$(function(){
		/************Expand all********************/
		if($("#newAllExpand")){
			$("#newAllExpand").click(function(){
				if(this.className == 'icon-resize-small'){
					this.className = 'icon-resize-full';
					$("#newSuite tr:even").each(function () {
						var node = $(this).find("td:eq(0)").children(".icon-minus");
						if(node[0]){
							node[0].className = 'icon-plus';
							$(this).next().css("display", "none");
						}
					});
				}else{
					this.className = 'icon-resize-small';
					$("#newSuite tr:even").each(function () {
						var node = $(this).find("td:eq(0)").children(".icon-plus");
						if(node[0]){
							node[0].className = "icon-minus";
							$(this).next().css("display", "");
						}
					});
				}
			});
		}

		if($("#oldAllExpand")){
			$("#oldAllExpand").click(function(){
				if(this.className == 'icon-resize-small'){
					this.className = 'icon-resize-full';
					$("#oldSuite tr:even").each(function () {
						var node = $(this).find("td:eq(0)").children(".icon-minus");
						if(node[0]){
							node[0].className = 'icon-plus';
							$(this).next().css("display", "none");
						}
					});
				}else{
					this.className = 'icon-resize-small';
					$("#oldSuite tr:even").each(function () {
						var node = $(this).find("td:eq(0)").children(".icon-plus");
						if(node[0]){
							node[0].className = "icon-minus";
							$(this).next().css("display", "");
						}
					});
				}
			});
		}
		
		/**************Selected all******************/
		if($("#newAllCheck")){
			$("#newAllCheck").click(function(){
				if(this.checked){
					$("#newSuite tr:even").each(function () {
						var inCheck = $(this).find("td:eq(1)").children("label").children("input");
						if(inCheck[0]){
							inCheck[0].checked = true;
							$(this).addClass("selected");
						}
					});
				}else{
					$("#newSuite tr:even").each(function () {
						var inCheck = $(this).find("td:eq(1)").children("label").children("input");
						if(inCheck[0]){
							inCheck[0].checked = false;
							$(this).removeClass("selected");
						}
					});
				}
			});
		}

		if($("#oldAllCheck")){
			$("#oldAllCheck").click(function(){
				if(this.checked){
					$("#oldSuite tr:even").each(function () {
						var inCheck = $(this).find("td:eq(1)").children("label").children("input");
						if(inCheck[0]){
							inCheck[0].checked = true;
							$(this).addClass("selected");
						}
					});
				}else{
					$("#oldSuite tr:even").each(function () {
						var inCheck = $(this).find("td:eq(1)").children("label").children("input");
						if(inCheck[0]){
							inCheck[0].checked = false;
							$(this).removeClass("selected");
						}
					});
				}
			});
		}
		/***********************Expand row for new suite table****************/
		if($(".icon-plus")){
			$(".icon-plus").bind("click", function(){
				if(this.className == 'icon-plus'){
					this.className = 'icon-minus';
				}else{
					this.className = 'icon-plus';
				}
				var nextTr = $(this).parent().parent().next();
				nextTr.toggle();
			});
		}
		/********************Select Row for new suite table******************/
		if($("input")){
			$("input").bind("click", function(){
				if($(this).parent().parent().is("td")){
					if(this.checked){
						$(this).parent().parent().parent().addClass("selected");
					}else{
						$(this).parent().parent().parent().removeClass("selected");
					}
				}
			});
		}
		
	});
</script>
</body>
</html>


效果:





  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值