kendou grid 合并列和行
来源:互联网 发布:web前端开发 薪资知乎 编辑:程序博客网 时间:2024/06/05 11:50
<div id="grid" style="border-top:solid 1px #000000"></div>
<script>
$("#grid").kendoGrid({
columns: [
{ field: "firstName" },
{ field: "lastName" }, /* group by this column to see the footer template */
{
field: "age",
aggregates: ["count", "min", "max"],
groupFooterTemplate: "age total: #: count #, min: #: min #, max: #: max #"
}
],
dataSource: {
data: [
{ firstName: "Jane", lastName: "Doe", age: 30 },
{ firstName: "Jane", lastName: "Doe", age: 30 },
{ firstName: "Sam", lastName: "Sam", age: 30 },
{ firstName: "Sam", lastName: "Sam", age: 30 },
{ firstName: "Sam", lastName: "Doe", age: 30 },
{ firstName: "John", lastName: "John", age: 30 },
{ firstName: "John", lastName: "John", age: 30 },
//{ firstName: "John", lastName: "Doe", age: 33 },
{ firstName: "dean", lastName: "x.liu", age: 30 },
{ firstName: "dean", lastName: "x.liu", age: 30 },
//{ firstName: "John", lastName: "Doe", age: 33 },
]
},
dataBound: function () {
$('#grid>.k-grid-content>table').each(function (index, item) {
var dimension_col = 1;
// First, scan first row of headers for the "Dimensions" column.
$('#grid>.k-grid-header>.k-grid-header-wrap>table').find('th').each(function () {
if ($(this).text() == 'firstName') {
// first_instance holds the first instance of identical td
var first_instance = null;
var rowspan = 0;
$(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;
rowspan = 0;
//$(first_instance).css('border-top', 'solid 1px #000000');
} else if (dimension_td.text() == first_instance.text()) {
// if current td is identical to the previous
// then remove the current td
//rowspan++;
$(item).find('tr').each(function () {
if ($(this).find('td:nth-child(' + dimension_col + ')').text() == first_instance.text()) {
rowspan++;
}
});
dimension_td.hide();
first_instance.attr('rowspan', rowspan);
rowspan = 0;
// increment the rowspan attribute of the first instance
//$(item).find('tr').each(function () {
// if ($(this).find('td:nth-child(' + dimension_col + ')').text() == first_instance.text()) {
// rowspan++;
// }
//});
//first_instance.attr('rowspan', first_instance.attr('rowspan') == "undefined" ? 2 : first_instance.attr('rowspan') + 1);
//first_instance.attr('rowspan', typeof first_instance.attr('rowspan') == "undefined" ? 2 : first_instance.attr('rowspan') + 1);
} else {
rowspan = 0;
// this cell is different from the last
first_instance = dimension_td;
$(first_instance).css('border-top', 'solid 1px #000000');
}
});
return;
}
dimension_col++;
});
});
}
});
</script>
总结:主要是使用jqeury选择器定位DOM元素,使用属性colspan'或者rowspan合并,然后将多余的列使用hide方法隐藏,否则会出现td多并且排版错乱
- kendou grid 合并列和行
- itext 合并列和行
- extjs grid行和列显示不同颜色
- Extjs 4.0 Grid 表格列合并代码
- extjs4 grid合并列和合并行
- Oracle中合并列和行
- table 合并相同的列和行
- HTML中简单的行合并和列合并
- WPF教程(二十九)Grid行和列
- Extjs Grid 合并两列显示的数据
- 行合并到列
- EXtjsgrid合并列行
- 合并列值和分析列值
- sencha grid templatecolumn模板列和actioncolumn
- 十二、UI-Grid 添加和删除列
- oracle和mysql多行的列合并
- 行转列,列分行,行合并列
- 设定Grid行或列的尺寸
- android Toast初探
- 组件模块化最佳实践
- 静态持续变量、内部链接性
- Java中的递归思想
- Python3面向对象编程笔记(一)
- kendou grid 合并列和行
- 各种算法OID
- strpos、 strstr、 substr三个函数的对比讲解
- windows调试 -- 创建.dump文件
- qduoj 生化危机&&ycb老师的电脑中毒了(邻接表)
- Hdu2544-最短路-【最短路】
- 650. 2 Keys Keyboard
- C++ Templates的多型威力(7)---《C++ Templates》
- Arduino学习日记一