锐英源软件
第一信赖

精通

英语

开源

擅长

开发

培训

胸怀四海 

第一信赖

当前位置:锐英源 / 开源技术 / EasyUI / 扩展行显示细节
服务方向
人工智能数据处理
人工智能培训
kaldi数据准备
小语种语音识别
语音识别标注
语音识别系统
语音识别转文字
kaldi开发技术服务
软件开发
运动控制卡上位机
机械加工软件
软件开发培训
Java 安卓移动开发
VC++
C#软件
汇编和破解
驱动开发
联系方式
固话:0371-63888850
手机:138-0381-0136
Q Q:396806883

EasyUI 扩展行显示细节


数据网格(datagrid)可以改变它的视图来显示不同的效果。使用详细视图,数据网格可以在数据行的左边显示展开按钮("+" 或者 "-")。用户可以展开行来显示附加的详细信息。

步骤 1:创建数据网格

<table id="dg" style="width:500px;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="60">Item ID</th>				
<th field="productid" width="80">Product ID</th>				
<th field="listprice" align="right" width="70">List Price</th>				
<th field="unitcost" align="right" width="70">Unit Cost</th>				
<th field="status" width="50" align="center">Status</th>			
</tr>		
</thead>	
</table>

步骤 2:为数据网格设置详细视图

为了使用详细视图,请记得在页面头部引用视图脚本文件。

<script type="text/javascript" src="http://www.w3cschool.cc/try/jeasyui/datagrid-detailview.js"></script>
$('#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({			
border:false,			
cache:false,			
href:'datagrid21_getdetail.php?itemid='+row.itemid,			
onLoad:function(){				
$('#dg').datagrid('fixDetailRowHeight',index);			
}		
});		
$('#dg').datagrid('fixDetailRowHeight',index);	
}
});

我们定义 'detailFormatter' 函数,告诉数据网格如何渲染详细视图。 这种情况下,我们返回一个简单的 '<div>' 元素,它将充当详细内容的容器。 注意,详细信息为空。当用户点击展开按钮('+')时,onExpandRow 事件将被触发。 所以我们可以写一些代码来加载ajax详细内容。 最后我们调用 'fixDetailRowHeight' 方法来固定当详细内容加载时的行高度。


步骤 3:服务器端代码

datagrid21_getdetail.php
&lt;?php	
include_once 'conn.php'; 	
$itemid = mysql_real_escape_string($_REQUEST['itemid']); 	
$rs = mysql_query("select *from item where itemid='$itemid'");	
$item = mysql_fetch_array($rs);?&gt; <table class="dv-table" border="0"style="width:100%;">	
<tr>		
<td rowspan="3" style="width:60px">			
&lt;?php				
$aa = explode('-',$itemid);				
$serno = $aa[1];				
$img = "images/shirt$serno.gif";				
echo "<img src=\"$img\" style=\"width:60px;margin-right:20px\" />";			
?&gt;		
</td>		
<td class="dv-label">Item ID: </td>		
<td>&lt;?php echo $item['itemid'];?&gt;</td>		
<td class="dv-label">Product ID:</td>		
<td>&lt;?php echo $item['productid'];?&gt;</td>	
</tr>	
<tr>		
<td class="dv-label">List Price: </td>		
<td>&lt;?php echo $item['listprice'];?&gt;</td>		
<td class="dv-label">Unit Cost:</td>		
<td>&lt;?php echo $item['unitcost'];?&gt;</td>	
</tr>	
<tr>		
<td class="dv-label">Attribute: </td>		
<td colspan="3">&lt;?php echo $item['attr1'];?&gt;</td>	
</tr>
</table>
友情链接
版权所有 Copyright(c)2004-2021 锐英源软件
公司注册号:410105000449586 豫ICP备08007559号 最佳分辨率 1024*768
地址:郑州大学北校区院(文化路97号院)内