REDIPS.table documentation

Namespace Summary
Constructor Attributes Constructor Name and Description
 
REDIPS.table Version 1.1.0.

REDIPS.table is a JavaScript library which enables dynamically merging and splitting table cells.

See:
Merge and split table cells with JavaScript
Field Summary
Field Attributes Field Name and Description
 
color.cell defines background color for marked table cell.
 
Enable / disable marking not empty table cells.
Method Summary
Method Attributes Method Name and Description
 
Method removes attached onmousedown event listener.
 
cell_index(flag)
Method displays cellIndex for each cell in tables.
 
column(table, mode, index)
Method adds / deletes table column.
 
mark(flag, el, row, col)
Method sets or removes mark from table cell.
 
merge(mode, clear, table)
Method merges marked table cells horizontally or vertically.
 
onmousedown(el, flag, type)
Method attaches or removes onmousedown event listener on TD elements depending on second parameter value (default is true).
 
row(table, mode, index)
Method adds / deletes table row.
 
split(mode, table)
Method splits marked table cell only if cell has colspan/rowspan greater then 1.
Field Detail

{Object} color
color.cell defines background color for marked table cell. If not set then background color will not be changed.
// set "#9BB3DA" as color for marked cell
REDIPS.table.color.cell = '#9BB3DA';
Default Value:
null

{Boolean} mark_nonempty
Enable / disable marking not empty table cells.
// allow marking only empty cells
REDIPS.table.mark_nonempty = false;
Default Value:
true
Method Detail

cell_ignore(c)
Method removes attached onmousedown event listener. Sometimes is needed to manually ignore some cells in table after row/column were dynamically added.
Parameters:
{HTMLElement|String} c
Cell id or cell reference of table that should be ignored (onmousedown event listener will be removed).

cell_index(flag)
Method displays cellIndex for each cell in tables. It is useful in debuging process.
Parameters:
{Boolean} flag
If set to true then cell content will be replaced with cell index.

column(table, mode, index)
Method adds / deletes table column. Last column will be assumed if index is omitted.
Parameters:
{HTMLElement|String} table
Table id or table reference.
{String} mode
Insert/delete table column
{Integer} index Optional
Index where column will be inserted or deleted. Last column will be assumed if index is not defined.

mark(flag, el, row, col)
Method sets or removes mark from table cell. It can be called on several ways: with direct cell address (cell reference or cell id) or with cell coordinates (row and column).
// set mark to the cell with "mycell" reference
REDIPS.table.mark(true, mycell);
 
// remove mark from the cell with id "a1"
REDIPS.table.mark(false, "a1");
 
// set mark to the cell with coordinates (1,2) on table with reference "mytable"   
REDIPS.table.mark(true, mytable, 1, 2);
 
// remove mark from the cell with coordinates (4,5) on table with id "t3"
REDIPS.table.mark(false, "t3", 4, 5);
Parameters:
{Boolean} flag
If set to true then TD will be marked, otherwise table cell will be cleaned.
{HTMLElement|String} el
Cell reference or id of table cell. Or it can be table reference or id of the table.
{Integer} row Optional
Row of the cell.
{Integer} col Optional
Column of the cell.

merge(mode, clear, table)
Method merges marked table cells horizontally or vertically.
Parameters:
{String} mode
Merge type: h – horizontally, v – vertically. Default is “h”.
{Boolean} clear Optional
true – cells will be clean (without mark) after merging, false – cells will remain marked after merging. Default is “true”.
{HTMLElement|String} table Optional
Table id or table reference.

onmousedown(el, flag, type)
Method attaches or removes onmousedown event listener on TD elements depending on second parameter value (default is true). If third parameter is set to “classname” then tables will be selected by class name (named in first parameter). All found tables will be saved in internal array. Sending reference in this case will not be needed when calling merge or split method. Table cells marked with class name “ignore” will not have attached onmousedown event listener (in short, these table cells will be ignored).
// activate onmousedown event listener on cells within table with id="mainTable"
REDIPS.table.onmousedown('mainTable', true);
 
// activate onmousedown event listener on cells for tables with class="blue"
REDIPS.table.onmousedown('blue', true, 'classname');
Parameters:
{String|HTMLElement} el
Container Id. TD elements within container will have added onmousewdown event listener.
{Boolean} flag Optional
If set to true then onmousedown event listener will be attached to every table cell.
{String} type Optional
If set to “class name” then all tables with a given class name (first parameter is considered as class name) will be initialized. Default is container/table reference or container/table id.

{HTMLElement} row(table, mode, index)
Method adds / deletes table row. If index is omitted then index of last row will be set.
Parameters:
{HTMLElement|String} table
Table id or table reference.
{String} mode
Insert/delete table row
{Integer} index Optional
Index where row will be inserted or deleted. Last row will be assumed if index is not defined.
Returns:
{HTMLElement} Returns reference of inserted row or NULL (in case of deleting row).

split(mode, table)
Method splits marked table cell only if cell has colspan/rowspan greater then 1.
Parameters:
{String} mode
Split type: h – horizontally, v – vertically. Default is “h”.
{HTMLElement|String} table Optional
Table id or table reference.

21 thoughts on “REDIPS.table documentation

  1. Hej, thanks for your great code.

    I hope you have a solution for my problem. In each table cell is a textarea with user input. If i load the table and init the REDIPS.table the table cells are empty. How can i keep the init content of table cell?

    Thanks

Leave a Comment