我在 Kendo UI 的官方文档中没有看到任何内容。只是检查是否有人进行了自定义以合并 Kendo UI 网格中的单元格。
我有这样的内容:
Technology Core Language & Communication 15
----------------------------------------------------------------------------------
Technology Mathematics & Application 20
----------------------------------------------------------------------------------
Technology Science Application & Understanding 30
---------------------------------------------------------------------------------
Communication Using language to reason, interpret & analyse 40
---------------------------------------------------------------------------------
Communication Using visualization for design/creating 40
我需要得到以下输出:
Technology Core Language & Communication 15
-----------------------------------------------------------------
Mathematics & Application 20
-----------------------------------------------------------------
Science Application & Understanding 30
---------------------------------------------------------------------------------
Communication Using language to reason, interpret & analyse 40
-----------------------------------------------------------------
Using visualization for design/creating 40
不知道如何使用模板来完成。
不支持合并 Kendo UI 网格中的单元格。
所以最后我决定在kendo ui网格渲染后合并单元格,所以我使用javascript在kendo ui Grid的DataBound事件中合并单元格。
function mergeGridRows(gridId, colTitle) {
$('#' + gridId + '>.k-grid-content>table').each(function (index, item) {
var dimension_col = 1;
// First, scan first row of headers for the "Dimensions" column.
$('#' + gridId + '>.k-grid-header>.k-grid-header-wrap>table').find('th').each(function () {
if ($(this).text() == colTitle) {
// first_instance holds the first instance of identical td
var first_instance = null;
$(item).find('tr').each(function () {
// find the td of the correct column (determined by the colTitle)
var dimension_td = $(this).find('td:nth-child(' + dimension_col + ')');
if (first_instance == null) {
first_instance = dimension_td;
} else if (dimension_td.text() == first_instance.text()) {
// if current td is identical to the previous
// then remove the current td
dimension_td.remove();
// increment the rowspan attribute of the first instance
first_instance.attr('rowspan', typeof first_instance.attr('rowspan') == "undefined" ? 2 : first_instance.attr('rowspan') + 1);
} else {
// this cell is different from the last
first_instance = dimension_td;
}
});
return;
}
dimension_col++;
});
});
}
更多细节 http://www.arsnova.cc/web-development-articles/2013-08-26/merging-table-cells-jquery-javascript
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)