Page tree
Skip to end of metadata
Go to start of metadata

Table extends Element

The API model used to edit tables.

Methods


deleteCol(startIndex[, endIndex])

  • startIndex <Number>  :  The start position of column to delete (starts from 0)
  • endIndex <Number> :  The end position of column to delete

Deletes the specified column from the table. The startIndex value starts from 0, and if endIndex is not specified, only the column corresponding to startIndex is deleted.

var table = editor.getAPIModelById('id');
table.deleteCol(1);	// Delete the second column
table.deleteCol(1,3); // Delete from second to fourth column

deleteRow(startIndex[, endIndex])

  • startIndex <Number>  :  The start position of row to delete (starts from 0)
  • endIndex <Number> :  The end position of row to delete

Deletes the specified row from the table. The startIndex value starts from 0, and if endIndex is not specified, only the row corresponding to startIndex is deleted.

var table = editor.getAPIModelById('id');
table.deleteRow(1);	// Delete the second row
table.deleteRow(1,3); // Delete from second to foruth row

deleteContents()

Deletes all contents of cells inside the table.

var table = editor.getAPIModelById('id');
table.deleteContents();

insertCol(index)

  • index <Number>  :  Position of the column to be added

Adds a column at the specified location.

var table = editor.getAPIModelById('id');
table.insertCol(1);

insertRow(index)

  • index <Number> :   Position of the row to be added

Adds a row at the specified location.

var table = editor.getAPIModelById('id');
table.insertRow(1);

mergeCell(startRowIndex, startColIndex, endRowIndex, endColIndex)

  • startRowIndex <Number> :  Start position of row to be merged
  • startColIndex <Number> :  Start position of column to be merged
  • endRowIndex <Number> :  End position of row to be merged
  • endColIndex <Number> :  End position of column to be merged

Merges the specified cells.

var table = editor.getAPIModelById('id');
table.mergeCell(0, 0, 1, 2);

replace(html)

  • html <String> :  The HTML String to replace.

Replaces the element itself with the HTML String passed as an argument.

var table = editor.getAPIModelById('id');
table.replace('<span>Table replaced</span>');

remove()

Removes the Element itself.

IF ALL ELEMENTS ARE REMOVED, ERRORS MAY OCCUR IN SUBSEQUENT OPERATIONS.

var table = editor.getAPIModelById('id');
table.remove();

setColWidth(index, value[, unit = 'px'])

  • index <Number> : Position of the column to set.
  • value : Width
  • unit : Unit of width('px', '%'). default 'px'.

지정된 열의 너비를 설정합니다.

var table = editor.getAPIModelById('id');
table.setColWidth(1, 100, 'px');
table.setColWidth(1, 20, '%');

setRowHeight(index, value)

  • index <Number> : Position of the row to set.
  • value : Height. Row height can only be set to 'px'.

Sets the height of the specified row.

var table = editor.getAPIModelById('id');
table.setRowHeight(1, 100);

setHeight(value[, unit = 'px'])

  • value<Number> : height
  • unit <String> : Unit of height ('px', '%'). default 'px'.

Sets the height of the table.

var table = editor.getAPIModelById('id');
table.setHeight(200);
table.setHeight(200, 'px');

setWidth(value[, unit = 'px'])

  • value<Number> : Width
  • unit <String> : Unit of width ('px', '%'). default 'px'.

Sets the width of the table.

var table = editor.getAPIModelById('id');
table.setWidth(400);
table.setWidth(100, '%');
  • No labels