easyUI 展开DataGrid里面的行显示详细信息
http://blog.csdn.net/yanghongchang_/article/details/7854156原著
datagrid 可以改变它的view(视图)去显示不同的效果.使用详细视图,datagrid可以显示展开按钮("+" 或者 "-")在数据行的左边,用户可以展开一个行去显示一个附加的详细信息.

步骤 1: 创建 DataGrid
- <table id="dg" style="width:500px;height:250px" url="data/datagrid_data.json" 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: 为DataGrid设置详细视图
使用详细视图,切记:引入视图script文件在你的页面的头部.
- <script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-detailview.js"></script>
- $('#dg').datagrid({
- view: detailview,
- detailFormatter:function(index,row){
- return '<div id="ddv-' + index + '" style="padding:5px 0"></div>';
- },
- onExpandRow: function(index,row){
- $('#ddv-'+index).panel({
- border:false,
- cache:false,
- href:'datagrid21_getdetail.php?itemid='+row.itemid,
- onLoad:function(){
- $('#dg').datagrid('fixDetailRowHeight',index);
- }
- });
- $('#dg').datagrid('fixDetailRowHeight',index);
- }
- });
我们定义detailFormatter函数告诉datagrid 如何渲染详细视图,在这种情况下,我们返回一个简单的 '<div>'元素,它将充当最为一个详细内容的容器,
注意:详细信息为空,当用户点击展开按钮('+'),onExpandRow事件将被触发,所以我们可以写一些代码去加载ajax详细内容,最后我们调用fixDetailRowHeight方法去固定行高度,当详细内容加载之后.
步骤 3: 服务器端代码
datagrid21_getdetail.php
- <?php
- $itemid = $_REQUEST['itemid'];
- $content = file_get_contents('data/datagrid_data.json');
- $data = json_decode($content,true);
- foreach($data['rows'] as $item){
- if ($item['itemid'] == $itemid){
- break;
- }
- }
- ?>
- <table class="dv-table" border="0" style="width:100%;">
- <tr>
- <td rowspan="3" style="width:60px">
- <?php
- echo "<img src=\"images/$itemid.gif\" style=\"height:50px\"/>";
- ?>
- </td>
- <td class="dv-label">Item ID: </td>
- <td><?php echo $item['itemid'];?></td>
- <td class="dv-label">Product ID:</td>
- <td><?php echo $item['productid'];?></td>
- </tr>
- <tr>
- <td class="dv-label">List Price: </td>
- <td><?php echo $item['listprice'];?></td>
- <td class="dv-label">Unit Cost:</td>
- <td><?php echo $item['unitcost'];?></td>
- </tr>
- <tr>
- <td class="dv-label">Attribute: </td>
- <td colspan="3"><?php echo $item['attr1'];?></td>
- </tr>
- </table>
easyUI 展开DataGrid里面的行显示详细信息的更多相关文章
- win10 显示详细信息窗格
win10 显示详细信息窗格 CreateTime--2018年5月26日09点13分 Author:Marydon 1.说明: win10无法像win7那样将详细信息窗格显示在窗口的底部,只能显 ...
- easyui的datagrid改变整行颜色
easyui的datagrid改变单元格颜色方法1:https://www.cnblogs.com/raitorei/p/10395233.html easyui的datagrid改变单元格颜色方法2 ...
- Easyui的datagrid的editor(行编辑器)如何扩展datetimebox类型
在easyui的datagrid扩展方法中添加这样的时间日期(datetimebox)代码块 放在 $.extend($.fn.datagrid.defaults.editors,{datetim ...
- 单击HighCharts柱形体弹框显示详细信息
上篇博客介绍了如何在HighCharts统计图表下生成表格,二者相互结合,可以对数据进行更好的统计分析.在统计的同时,如果需要想要及时查看详细信息的话,就得再加一个功能,就是单击柱形体,显示该项下的详 ...
- html5,单击显示详细信息
<details open=""> <summary>点击率</summary> <p>详细信息</p&g ...
- datagrid 列鼠标悬浮显示全部信息
首次发表随笔,且是java新手,求不黑,可能在高手眼里好笑,嘿嘿1,样式设置超过字数限制显示省略号:<style type="text/css"> .datagrid- ...
- easyui,datagrid表格,行内可编辑
最近用到easyui,需要表格内编辑,但是我同一个页面有多个表格,把官方的代码修改了一下,如下: HTML代码 <table id="dg" class="easy ...
- EasyUI的datagrid有值但是显示不出来
$("#goodsList").datagrid({ url: "../Ajax/GoodsAjax.ashx", queryParams: { cmd ...
- easyui 中datagrid 点击行的事件
$('#datagrid 的ID').datagrid({ onClickRow:function(index,data) { ...
随机推荐
- 第五篇 Nginx的简单配置
先安装: sudo apt-get install nginx php5-fpm 我是在新安装的Ubuntu13上测试通过的,真的只安装这两个东西就够了. 然后编辑配置文件. sudo gedit / ...
- Linux查看物理CPU个数、核数,逻辑CPU个数
学习swoole的时候,建议开启的worker进程数为cpu核数的1-4倍.于是就学习怎么查看CPU核数 # 查看物理CPU个数 cat /proc/cpuinfo| grep "physi ...
- Django基础(五)
Django admin 自带的验证: from django.contrib.auth.decorators import login_required from django.contrib.au ...
- Java-API-POI-Excel:SXSSFWorkbook Documentation
ylbtech-Java-API-POI-Excel:SXSSFWorkbook Documentation 1.返回顶部 1. org.apache.poi.xssf.streaming Class ...
- rails的respond to format
Here are all the default Rails Mime Types: "*/*" => :all "text/plain" => : ...
- select *和select 全部
select *和select 全部字段 在查询上效果是一样的,速度也是一样的. 不过理论上来说select *反而会快点. 因为 1.select 全部字段在数据传输上消耗会更多,如果几百个字段这个 ...
- C Primer Plus学习笔记(五)- C控制语句:循环
伪代码的概念: 伪代码是一种用简单的句子表示程序思路的方法,它与计算机语言的形式相对应.伪代码有助于设计程序的逻辑.确定程序的逻辑无误之后,再把伪代码翻译成实际的编程代码.使用伪代码的好处之一是,可以 ...
- [更新中]【fit-flow使用总结】djang开发中git flow使用总结
djang开发中git flow使用总结 初次接触可以先看看此链接上关于git flow的东西http://danielkummer.github.io/git-flow-cheatsheet/ind ...
- CSS3图片以中心缩放,放大超出隐藏实现
首页,重点是有一个包裹img标签的容器,这里我们给该容器设置一个class为selfScale <div class="selfScale"> <img sr=& ...
- Oracle、SqlServer——基础知识——oracle 与 SqlServer 的区别(未完工)
一. oracle 与 SqlServer 的区别: 类别 oracle SqlServer 连接字符串 || + 变量 变量名 @变量名 初始赋值 := = SQL语句赋值 into = 绑定变量 ...