≡
×
Plus
Manual
Examples
Reference
Download
Blog
Community
Support
colspan or rowspan to tbody
colspan or rowspan to tbody
BFG86
Posts: 10
Questions: 0
Answers: 0
June 2013
edited June 2013
in
General
Hello everyone! =)
Please advise me how to apply colspan or rowspan for table cells(tbody>td)?
Thank you!
Replies
BFG86
Posts: 10
Questions: 0
Answers: 0
June 2013
Datatable init:
[code]
var tFlowRate = $("#tFlowRate").dataTable({
"bDeferRender": true,
"bPaginate": false,
"bFilter": false,
"bSort": false,
"bJQueryUI": true,
"bInfo": false,
"sScrollY": "700px",
"sScrollX": "102%",
"bScrollCollapse": true,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [0] }
],
"fnRowCallback": function (nRow, aData, iDataIndex, oSettings) {
if ((aData[1].search('Сумма') != -1) || (aData[0].search('Сумма') != -1)) {
var zTree = $.fn.zTree.getZTreeObj("treetmpar"),
checkCount = zTree.getCheckedNodes(true).length;
$(nRow).children("td:eq(0)").html("");
$(nRow).children("td:eq(" + checkCount + ")").html(aData[1]);
}
},
"fnDrawCallback": function (oSettings) {
if (oSettings.aiDisplay.length == 0) {
return;
}
var nTrs = $('#tFlowRate tbody tr');
var iColspan = nTrs[0].getElementsByTagName('td').length;
var sLastGroup = "";
for (var i = 0, nTrsL = nTrs.length ; i < nTrsL; i++) {
var iDisplayIndex = oSettings._iDisplayStart + i;
var sGroup = oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]]._aData[0];
if (sGroup != sLastGroup) {
var nGroup = document.createElement('tr');
var nCell = document.createElement('td');
nCell.colSpan = iColspan;
nCell.className = "group";
nCell.innerHTML = sGroup;
nGroup.appendChild(nCell);
nTrs[i].parentNode.insertBefore(nGroup, nTrs[i]);
sLastGroup = sGroup;
}
}
}
});
[/code]
I need to add $(nRow).children("td:eq(0)").attr("colspan", 15); to the "fnRowCallback", but the cells are shifted.
BFG86
Posts: 10
Questions: 0
Answers: 0
June 2013
Created a sample: http://live.datatables.net/iguyar/4/edit
BFG86
Posts: 10
Questions: 0
Answers: 0
July 2013
no ideas? =)
sutaria
Posts: 1
Questions: 0
Answers: 0
October 2013
@BFG86 - Did you figure this one out? I am having same issues
allan
Posts: 65,825
Questions: 1
Answers: 10,952
Site admin
October 2013
DataTables does not support colspan or rowspan in the tbody at this time. Sorry.
Allan
funny
Posts: 1
Questions: 0
Answers: 0
November 2013
@allan
when does DataTables support colspan or rowspan in the tbody ?
allan
Posts: 65,825
Questions: 1
Answers: 10,952
Site admin
November 2013
Not likely any time soon. If someone is willing to sponsor the work, please get in touch with me directly, but for the time being it isn't planning in the 1.x series at all.
Allan
This discussion has been closed.
Replies
[code]
var tFlowRate = $("#tFlowRate").dataTable({
"bDeferRender": true,
"bPaginate": false,
"bFilter": false,
"bSort": false,
"bJQueryUI": true,
"bInfo": false,
"sScrollY": "700px",
"sScrollX": "102%",
"bScrollCollapse": true,
"sPaginationType": "full_numbers",
"aoColumnDefs": [
{ "bVisible": false, "aTargets": [0] }
],
"fnRowCallback": function (nRow, aData, iDataIndex, oSettings) {
if ((aData[1].search('Сумма') != -1) || (aData[0].search('Сумма') != -1)) {
var zTree = $.fn.zTree.getZTreeObj("treetmpar"),
checkCount = zTree.getCheckedNodes(true).length;
$(nRow).children("td:eq(0)").html("");
$(nRow).children("td:eq(" + checkCount + ")").html(aData[1]);
}
},
"fnDrawCallback": function (oSettings) {
if (oSettings.aiDisplay.length == 0) {
return;
}
var nTrs = $('#tFlowRate tbody tr');
var iColspan = nTrs[0].getElementsByTagName('td').length;
var sLastGroup = "";
for (var i = 0, nTrsL = nTrs.length ; i < nTrsL; i++) {
var iDisplayIndex = oSettings._iDisplayStart + i;
var sGroup = oSettings.aoData[oSettings.aiDisplay[iDisplayIndex]]._aData[0];
if (sGroup != sLastGroup) {
var nGroup = document.createElement('tr');
var nCell = document.createElement('td');
nCell.colSpan = iColspan;
nCell.className = "group";
nCell.innerHTML = sGroup;
nGroup.appendChild(nCell);
nTrs[i].parentNode.insertBefore(nGroup, nTrs[i]);
sLastGroup = sGroup;
}
}
}
});
[/code]
I need to add $(nRow).children("td:eq(0)").attr("colspan", 15); to the "fnRowCallback", but the cells are shifted.
Allan
when does DataTables support colspan or rowspan in the tbody ?
Allan