http://blog.csdn.net/yanghongchang_/article/details/7854156原著

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

查看 Demo

步骤 1: 创建 DataGrid

  1. <table id="dg" style="width:500px;height:250px" url="data/datagrid_data.json" title="DataGrid - Expand Row" singleselect="true" fitcolumns="true">
  2. <thead>
  3. <tr>
  4. <th field="itemid" width="60">Item ID</th>
  5. <th field="productid" width="80">Product ID</th>
  6. <th field="listprice" align="right" width="70">List Price</th>
  7. <th field="unitcost" align="right" width="70">Unit Cost</th>
  8. <th field="status" width="50" align="center">Status</th>
  9. </tr>
  10. </thead>
  11. </table>

步骤 2: 为DataGrid设置详细视图

使用详细视图,切记:引入视图script文件在你的页面的头部.

  1. <script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-detailview.js"></script>
  1. $('#dg').datagrid({
  2. view: detailview,
  3. detailFormatter:function(index,row){
  4. return '<div id="ddv-' + index + '" style="padding:5px 0"></div>';
  5. },
  6. onExpandRow: function(index,row){
  7. $('#ddv-'+index).panel({
  8. border:false,
  9. cache:false,
  10. href:'datagrid21_getdetail.php?itemid='+row.itemid,
  11. onLoad:function(){
  12. $('#dg').datagrid('fixDetailRowHeight',index);
  13. }
  14. });
  15. $('#dg').datagrid('fixDetailRowHeight',index);
  16. }
  17. });

我们定义detailFormatter函数告诉datagrid 如何渲染详细视图,在这种情况下,我们返回一个简单的 '<div>'元素,它将充当最为一个详细内容的容器,

注意:详细信息为空,当用户点击展开按钮('+'),onExpandRow事件将被触发,所以我们可以写一些代码去加载ajax详细内容,最后我们调用fixDetailRowHeight方法去固定行高度,当详细内容加载之后.

步骤 3: 服务器端代码

datagrid21_getdetail.php

  1. <?php
  2. $itemid = $_REQUEST['itemid'];
  3. $content = file_get_contents('data/datagrid_data.json');
  4. $data = json_decode($content,true);
  5. foreach($data['rows'] as $item){
  6. if ($item['itemid'] == $itemid){
  7. break;
  8. }
  9. }
  10. ?>
  11. <table class="dv-table" border="0" style="width:100%;">
  12. <tr>
  13. <td rowspan="3" style="width:60px">
  14. <?php
  15. echo "<img src=\"images/$itemid.gif\" style=\"height:50px\"/>";
  16. ?>
  17. </td>
  18. <td class="dv-label">Item ID: </td>
  19. <td><?php echo $item['itemid'];?></td>
  20. <td class="dv-label">Product ID:</td>
  21. <td><?php echo $item['productid'];?></td>
  22. </tr>
  23. <tr>
  24. <td class="dv-label">List Price: </td>
  25. <td><?php echo $item['listprice'];?></td>
  26. <td class="dv-label">Unit Cost:</td>
  27. <td><?php echo $item['unitcost'];?></td>
  28. </tr>
  29. <tr>
  30. <td class="dv-label">Attribute: </td>
  31. <td colspan="3"><?php echo $item['attr1'];?></td>
  32. </tr>
  33. </table>

easyUI 展开DataGrid里面的行显示详细信息的更多相关文章

  1. win10 显示详细信息窗格

      win10 显示详细信息窗格 CreateTime--2018年5月26日09点13分 Author:Marydon 1.说明: win10无法像win7那样将详细信息窗格显示在窗口的底部,只能显 ...

  2. easyui的datagrid改变整行颜色

    easyui的datagrid改变单元格颜色方法1:https://www.cnblogs.com/raitorei/p/10395233.html easyui的datagrid改变单元格颜色方法2 ...

  3. Easyui的datagrid的editor(行编辑器)如何扩展datetimebox类型

    在easyui的datagrid扩展方法中添加这样的时间日期(datetimebox)代码块 放在   $.extend($.fn.datagrid.defaults.editors,{datetim ...

  4. 单击HighCharts柱形体弹框显示详细信息

    上篇博客介绍了如何在HighCharts统计图表下生成表格,二者相互结合,可以对数据进行更好的统计分析.在统计的同时,如果需要想要及时查看详细信息的话,就得再加一个功能,就是单击柱形体,显示该项下的详 ...

  5. html5,单击显示详细信息

    <details open="">    <summary>点击率</summary>        <p>详细信息</p&g ...

  6. datagrid 列鼠标悬浮显示全部信息

    首次发表随笔,且是java新手,求不黑,可能在高手眼里好笑,嘿嘿1,样式设置超过字数限制显示省略号:<style type="text/css"> .datagrid- ...

  7. easyui,datagrid表格,行内可编辑

    最近用到easyui,需要表格内编辑,但是我同一个页面有多个表格,把官方的代码修改了一下,如下: HTML代码 <table id="dg" class="easy ...

  8. EasyUI的datagrid有值但是显示不出来

    $("#goodsList").datagrid({  url: "../Ajax/GoodsAjax.ashx",  queryParams:  {  cmd ...

  9. easyui 中datagrid 点击行的事件

    $('#datagrid 的ID').datagrid({                onClickRow:function(index,data)                {        ...

随机推荐

  1. 第五篇 Nginx的简单配置

    先安装: sudo apt-get install nginx php5-fpm 我是在新安装的Ubuntu13上测试通过的,真的只安装这两个东西就够了. 然后编辑配置文件. sudo gedit / ...

  2. Linux查看物理CPU个数、核数,逻辑CPU个数

    学习swoole的时候,建议开启的worker进程数为cpu核数的1-4倍.于是就学习怎么查看CPU核数 # 查看物理CPU个数 cat /proc/cpuinfo| grep "physi ...

  3. Django基础(五)

    Django admin 自带的验证: from django.contrib.auth.decorators import login_required from django.contrib.au ...

  4. Java-API-POI-Excel:SXSSFWorkbook Documentation

    ylbtech-Java-API-POI-Excel:SXSSFWorkbook Documentation 1.返回顶部 1. org.apache.poi.xssf.streaming Class ...

  5. rails的respond to format

    Here are all the default Rails Mime Types: "*/*" => :all "text/plain" => : ...

  6. select *和select 全部

    select *和select 全部字段 在查询上效果是一样的,速度也是一样的. 不过理论上来说select *反而会快点. 因为 1.select 全部字段在数据传输上消耗会更多,如果几百个字段这个 ...

  7. C Primer Plus学习笔记(五)- C控制语句:循环

    伪代码的概念: 伪代码是一种用简单的句子表示程序思路的方法,它与计算机语言的形式相对应.伪代码有助于设计程序的逻辑.确定程序的逻辑无误之后,再把伪代码翻译成实际的编程代码.使用伪代码的好处之一是,可以 ...

  8. [更新中]【fit-flow使用总结】djang开发中git flow使用总结

    djang开发中git flow使用总结 初次接触可以先看看此链接上关于git flow的东西http://danielkummer.github.io/git-flow-cheatsheet/ind ...

  9. CSS3图片以中心缩放,放大超出隐藏实现

    首页,重点是有一个包裹img标签的容器,这里我们给该容器设置一个class为selfScale <div class="selfScale"> <img sr=& ...

  10. Oracle、SqlServer——基础知识——oracle 与 SqlServer 的区别(未完工)

    一. oracle 与 SqlServer 的区别: 类别 oracle SqlServer 连接字符串 || + 变量 变量名 @变量名 初始赋值 := = SQL语句赋值 into = 绑定变量 ...