js 显示信息问题,开始列中只显示主要信息,点击按钮显示其他信息,再次...
发布网友
发布时间:2022-04-30 14:17
我来回答
共2个回答
热心网友
时间:2022-04-24 20:38
这效果对吧,easyui的 datagrid,你看下吧
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="keywords" content="jquery,ui,easy,easyui,web">
<meta name="description" content="easyui help you build your web page easily!">
<title>Expand row in DataGrid to show details - jQuery EasyUI Demo</title>
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-detailview.js"></script>
</head>
<body>
<h2>Expand row in DataGrid to show details</h2>
<div class="demo-info" style="margin-bottom:10px">
<div class="demo-tip icon-tip"> </div>
<div>Click the expand button to expand row and view details.</div>
</div>
<table id="dg" style="width:700px;height:250px"
url="datagrid8_getdata.php"
pagination="true" sortName="itemid" sortOrder="desc"
title="DataGrid - Expand Row"
singleSelect="true" fitColumns="true">
<thead>
<tr>
<th field="itemid" width="80">Item ID</th>
<th field="proctid" width="100">Proct ID</th>
<th field="listprice" align="right" width="80">List Price</th>
<th field="unitcost" align="right" width="80">Unit Cost</th>
<th field="attr1" width="220">Attribute</th>
<th field="status" width="60" align="center">Status</th>
</tr>
</thead>
</table>
<script type="text/javascript">
$(function(){
$('#dg').datagrid({
view: detailview,
detailFormatter:function(index,row){
return '<div class="ddv" style="padding:5px 0"></div>';
},
onExpandRow: function(index,row){
var ddv = $(this).datagrid('getRowDetail',index).find('div.ddv');
ddv.panel({
height:80,
border:false,
cache:false,
href:'datagrid21_getdetail.php?itemid='+row.itemid,
onLoad:function(){
$('#dg').datagrid('fixDetailRowHeight',index);
}
});
$('#dg').datagrid('fixDetailRowHeight',index);
}
});
});
</script>
</body>
</html>
热心网友
时间:2022-04-24 21:56
<body>
<script type="text/javascript">
function test(obj,testid){
if(document.getElementById(testid).style.display == 'none'){
obj.innerHTML = "隐藏";
document.getElementById(testid).style.display='block';
} else {
obj.innerHTML = "显示";
document.getElementById(testid).style.display='none';
}
}
</script>
<table border="1">
<tr>
<td>
内容 <a onclick="test(this,'div1')">显示</a>
<div style="display: none;" id="div1">
<table>
<tr>
<td>你自定义的表格内容</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</body>
你试试是不是想要的效果