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. python 集合和深浅copy

    #1数据类型的补充#2.集合set#3.深浅copy 补充:str --> bytes s.encode('gbk')bytes --> str s.decode('gbk') 1.数据类 ...

  2. keepalived之 Keepalived 原理(定义、VRRP 协议、VRRP 工作机制)

    1.Keepalived 定义 Keepalived 是一个基于VRRP协议来实现的LVS服务高可用方案,可以利用其来避免单点故障.一个LVS服务会有2台服务器运行Keepalived,一台为主服务器 ...

  3. [转]移动H5前端性能优化指南

    移动H5前端性能优化指南 概述 1. PC优化手段在Mobile侧同样适用2. 在Mobile侧我们提出三秒种渲染完成首屏指标3. 基于第二点,首屏加载3秒完成或使用Loading4. 基于联通3G网 ...

  4. 配置文件的继承与覆盖: Machine.config / Web.config /子目录 Web.config

    C#有三种级别的配置文件: 机器级别 machine.config 在 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.c ...

  5. Qt多选框

    1.获取并显示复选框文本内容 ui->label->setText(ui->comboBox->currentText());

  6. Day1--Python基础1--下半部分

    一..pyc是什么 1. Python是一门解释型语言? 我初学Python时,听到的关于Python的第一句话就是,Python是一门解释性语言,我就这样一直相信下去,直到发现了*.pyc文件的存在 ...

  7. mongoTemplate操作内嵌文档

    关系型数据库中,表与表的关联关系有1:1,也有1:n的.在java的面向对象的世界里就是主对象嵌子对象,与主对象嵌集合<子对象>的两种形式. 主对象嵌子对象操作: 新增.修改都直接用如下方 ...

  8. iOS按home键后程序的状态变化

    iOS 的应用里的几种状态: active: 应用在前台正常运行 background: 应用在后台,并且在执行代码. inactive: 这个状态是应用从一个状态向另一个状态的过渡 suspende ...

  9. Python No module named pkg_resources

    好记性不如烂笔头. I encountered the same ImportError today while trying to use pip. Somehow the setuptools p ...

  10. VotingClassifier

    scores : array of float, shape=(len(list(cv)),) Array of scores of the estimator for each run of the ...