jQuery EasyUI使用教程:合并数据网格的单元格
文章标签:
jquery select设置选中
数据网格经常需要合并多个单元格,本教程将教会您在数据网格中如何合并单元格。
合并数据网格的单元格,您只需要简单地调用'mergeCells'方法并传入合并信息参数,告诉数据网格如何合并单元格。在合并的单元格中,除了第一个单元格以外,其他的单元格在合并后会被隐藏。
创建数据网格
<table id="tt" title="Merge Cells" style="width:550px;height:250px" url="data/datagrid_data.json" singleSelect="true" iconCls="icon-save" rownumbers="true" idField="itemid" pagination="true"> <thead frozen="true"> <tr> <th field="productid" width="80" formatter="formatProduct">Product ID</th> <th field="itemid" width="100">Item ID</th> </tr> </thead> <thead> <tr> <th colspan="2">Price</th> <th rowspan="2" field="attr1" width="150">Attribute</th> <th rowspan="2" field="status" width="60" align="center">Stauts</th> </tr> <tr> <th field="listprice" width="80" align="right">List Price</th> <th field="unitcost" width="80" align="right">Unit Cost</th> </tr> </thead> </table>
合并单元格
当数据加载时,我们在数据网格中合并单元格,因此在onLoadSuccess回调函数中放置下面的代码。
$('#tt').datagrid({ onLoadSuccess:function{ var merges = [{ index:2, rowspan:2 },{ index:5, rowspan:2 },{ index:7, rowspan:2 }]; for(var i=0; i <merges.length; i++) $('#tt').datagrid('mergeCells',{ index:merges[i].index, field:'productid', rowspan:merges[i].rowspan }); } });
购买jQuery EasyUI最新正版授权!详情请"咨询在线客服"
葡萄城经典UI产品新年大促,惊喜折扣礼品送不停!
慧都科技,十三年行业经验,专注提供软件技术整体解决方案,致力打造全球最大的软件技术一站式服务平台。
慧都控件|帮助企业打造成功软件
慧都提供全球优质控件产品/控件培训/项目定制开发/方案咨询/现场实施/项目外包/专业测试
微信ID:EVGET_Huidu
企业QQ:800018081|电话:023-66090381
扫码关注微信