原創|使用教程|編輯:龔雪|2016-03-10 09:12:41.000|閱讀 647 次
概述:數據網格經常需要合并多個單元格,本教程將教會您在數據網格中如何合并單元格。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
Kendo UI for jQuery——創建現代Web應用程序的最完整UI庫!查看詳情>>>
數據網格經常需要合并多個單元格,本教程將教會您在數據網格中如何合并單元格。
合并數據網格的單元格,您只需要簡單地調用'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 }); } });
下載EasyUI示例:
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:慧都控件網