A
adam_a_knight
Hi everyone,
Just working on a problem hope someone can help.
I have created a function to modify table elements and have had some
success with merging columns left and right.
However, i can't seem to merge row columns below or above. It works
for the first couple of times then gives a message that the object to
be merged doesn't exist
I know it is because the underlining table structure is changing..but
not sure how to get around it.
HTML AREA 3 does it also..
Thanks
AJ
function getRowSpan(selectedCell,mergeCell)
{
var currentSpan = (!selectedCell.rowSpan)? 1 : selectedCell.rowSpan;
var mergeSpan = (!mergeCell.rowSpan)? 1 : mergeCell.rowSpan;
\\can't find merge cell after a couple of columns have had their
rows merged.
var rowSpan = currentSpan + mergeSpan;
return rowSpan;
}
function mergeTableCells(mergeVal,range)
{
var obj = range.parentElement();
switch (mergeVal)
{
case "below":
//add row span of columns/row.
obj.parentNode.childNodes[obj.cellIndex].rowSpan =
getRowSpan(
obj.parentNode.cells[obj.cellIndex],
obj.parentNode.nextSibling.cells [obj.cellIndex]);
//delete column at same cell index in row below.
obj.parentNode.nextSibling.removeChild(
obj.parentNode.nextSibling.childNodes[obj.cellIndex]);
break;
}
}
Just working on a problem hope someone can help.
I have created a function to modify table elements and have had some
success with merging columns left and right.
However, i can't seem to merge row columns below or above. It works
for the first couple of times then gives a message that the object to
be merged doesn't exist
I know it is because the underlining table structure is changing..but
not sure how to get around it.
HTML AREA 3 does it also..
Thanks
AJ
function getRowSpan(selectedCell,mergeCell)
{
var currentSpan = (!selectedCell.rowSpan)? 1 : selectedCell.rowSpan;
var mergeSpan = (!mergeCell.rowSpan)? 1 : mergeCell.rowSpan;
\\can't find merge cell after a couple of columns have had their
rows merged.
var rowSpan = currentSpan + mergeSpan;
return rowSpan;
}
function mergeTableCells(mergeVal,range)
{
var obj = range.parentElement();
switch (mergeVal)
{
case "below":
//add row span of columns/row.
obj.parentNode.childNodes[obj.cellIndex].rowSpan =
getRowSpan(
obj.parentNode.cells[obj.cellIndex],
obj.parentNode.nextSibling.cells [obj.cellIndex]);
//delete column at same cell index in row below.
obj.parentNode.nextSibling.removeChild(
obj.parentNode.nextSibling.childNodes[obj.cellIndex]);
break;
}
}