课程表

jEasyUI 应用

jEasyUI 拖放

jEasyUI 菜单与按钮

jEasyUI 布局

jEasyUI 数据网格

jEasyUI 窗口

jEasyUI 树形菜单

jEasyUI 表单

jEasyUI 参考手册

工具箱
速查手册

jEasyUI 合并单元格

当前位置:免费教程 » JS/JS库/框架 » jQuery EasyUI

数据网格(datagrid)经常需要合并一些单元格。本教程将向您展示如何在数据网格(datagrid)中合并单元格。

为了合并数据网格(datagrid)单元格,只需简单地调用 'mergeCells' 方法,并传入合并信息参数,告诉数据网格(datagrid)如何合并单元格。在所有合并的单元格中,除了第一个单元格,其它单元格在合并后被隐藏。

创建数据网格(DataGrid)

  1. <table id="tt" title="Merge Cells" style="width:550px;height:250px"
  2. url="data/datagrid_data.json"
  3. singleSelect="true" iconCls="icon-save" rownumbers="true"
  4. idField="itemid" pagination="true">
  5. <thead frozen="true">
  6. <tr>
  7. <th field="productid" width="80" formatter="formatProduct">Product ID</th>
  8. <th field="itemid" width="100">Item ID</th>
  9. </tr>
  10. </thead>
  11. <thead>
  12. <tr>
  13. <th colspan="2">Price</th>
  14. <th rowspan="2" field="attr1" width="150">Attribute</th>
  15. <th rowspan="2" field="status" width="60" align="center">Stauts</th>
  16. </tr>
  17. <tr>
  18. <th field="listprice" width="80" align="right">List Price</th>
  19. <th field="unitcost" width="80" align="right">Unit Cost</th>
  20. </tr>
  21. </thead>
  22. </table>

合并单元格

当数据加载之后,我们合并数据网格(datagrid)中的一些单元格,所以放置下面的代码在 onLoadSuccess 回调函数中。

  1. $('#tt').datagrid({
  2. onLoadSuccess:function(){
  3. var merges = [{
  4. index:2,
  5. rowspan:2
  6. },{
  7. index:5,
  8. rowspan:2
  9. },{
  10. index:7,
  11. rowspan:2
  12. }];
  13. for(var i=0; i<merges.length; i++)
  14. $('#tt').datagrid('mergeCells',{
  15. index:merges[i].index,
  16. field:'productid',
  17. rowspan:merges[i].rowspan
  18. });
  19. }
  20. });

下载 jQuery EasyUI 实例

jeasyui-datagrid-datagrid13.zip

转载本站内容时,请务必注明来自W3xue,违者必究。
 友情链接:直通硅谷  点职佳  北美留学生论坛

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号