Back to Devexpress

Table Class

aspnetcore-js-devexpress-dot-richedit-a79e6d55.md

latest9.7 KB
Original Source

Table Class

Defines a table in the document.

Declaration

ts
export class Table extends TableElementBase

Remarks

javascript
richEdit.beginUpdate();
richEdit.history.beginTransaction();
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
var columnCount = 5;
var rowCount = 5;
var table = subDocument.tables.create(position, columnCount, rowCount);
for (var rowInd = 0, row; row = table.rows.getByIndex(rowInd); rowInd++) {
    for (var cellInd = 0, cell; cell = row.cells.getByIndex(cellInd); cellInd++) {
        subDocument.insertText(cell.interval.start, "Row[" + rowInd + "].Cell[" + cellInd + "]");
    }
}
richEdit.history.endTransaction();
richEdit.endUpdate();

Properties

autoFit Property

Specifies whether the table automatically adjusts its width to fit content.

Declaration

ts
get autoFit(): boolean
set autoFit(value: boolean)

Property Value

TypeDescription
boolean

true if the table automatically adjusts its width to fit content; otherwise, false.

|

Remarks

A table can automatically adjust its width to fit content. Use the autoFit property to identify whether size adjustment is enabled.

backgroundColor Property

Specifies the table’s background color.

Declaration

ts
get backgroundColor(): string
set backgroundColor(value: string)

Property Value

TypeDescription
string

The table’s background color.

|

Remarks

The backgroundColor property allows you to obtain and change the table’s background color.

Note

A cell’s background (TableCell.backgroundColor) overlaps the table’s background (Table.backgroundColor).

borders Property

Specifies the table’s border settings.

Declaration

ts
get borders(): TableBorders
set borders(value: ITableBorders)

Property Value

TypeDescription
TableBorders

Table border settings.

|

Remarks

Specify the borders property to configure a table’s border settings.

cellMargins Property

Specifies margin settings of all cells in the table.

Declaration

ts
get cellMargins(): Margins
set cellMargins(value: IMargins)

Property Value

TypeDescription
Margins

An object that contains margin settings.

|

Remarks

Use the cellMargins property to access and customize the margins of all table cells.

Note

A cell’s margins property takes priority over the table’s cellMargins property.

contentHorizontalAlignment Property

Specifies the horizontal alignment of table content.

Declaration

ts
get contentHorizontalAlignment(): TableContentHorizontalAlignment | null
set contentHorizontalAlignment(value: TableContentHorizontalAlignment)

Property Value

TypeDescription
TableContentHorizontalAlignment

An enumeration value.

|

Remarks

Use the contentHorizontalAlignment property to horizontally align content in all table cells.

Note

A cell’s contentHorizontalAlignment property takes priority over the table’s contentHorizontalAlignment property.

contentVerticalAlignment Property

Specifies the vertical alignment of table content.

Declaration

ts
get contentVerticalAlignment(): TableContentVerticalAlignment | null
set contentVerticalAlignment(value: TableContentVerticalAlignment)

Property Value

TypeDescription
TableContentVerticalAlignment

An enumeration value.

|

Remarks

Use the contentHorizontalAlignment property to horizontally align content in all table cells.

Note

A cell’s contentHorizontalAlignment property takes priority over the table’s contentHorizontalAlignment property.

index Property

Gets an index of the table.

Declaration

ts
get index(): number

Property Value

TypeDescription
number

The table’s index.

|

Remarks

Use the index to access the corresponding table by the TableCollection.getByIndex method.

interval Property

Gets the text buffer interval occupied by the current table element.

Declaration

ts
get interval(): Interval

Property Value

TypeDescription
Interval

An object that contains the interval settings.

|

parentCell Property

Returns the cell that contains the current table.

Declaration

ts
get parentCell(): TableCell | null

Property Value

TypeDescription
TableCell

The cell that contains the current table; null if the table is not nested.

|

rows Property

Provides access to a collection of table rows.

Declaration

ts
get rows(): TableRowCollection

Property Value

TypeDescription
TableRowCollection

An array of TableRow objects that store information about individual table rows.

|

styleName Property

Specifies the table style name.

Declaration

ts
get styleName(): string
set styleName(value: string)

Property Value

TypeDescription
string

The table style name.

|

Remarks

Use the styleName property to customize table appearance. Specify the tableStyleOptions property to apply/remove special formatting from the first, last, and odd columns and rows.

Note

Style options do not affect table appearance if the Normal Table or Grid Table Light style is applied to the table.

tableStyleOptions Property

Specifies style options applied to the table.

Declaration

ts
get tableStyleOptions(): TableStyleOptions
set tableStyleOptions(value: TableStyleOptions)

Property Value

TypeDescription
TableStyleOptions

Table style options.

|

Remarks

Specify the tableStyleOptions property to apply/remove special formatting from the first, last, and odd columns and rows.

Note

Style options do not affect table appearance if the Normal Table or Grid Table Light style is applied to the table.

width Property

Specifies the table’s width settings.

Declaration

ts
get width(): TableWidth
set width(value: TableWidth)

Property Value

TypeDescription
TableWidth

An object that contains width settings.

|

Remarks

Use the Table.width or TableCell.width property to specify the table or cell width.

Methods

delete Method

Deletes the current table.

Declaration

ts
delete(): void

Remarks

javascript
var subDocument = richEdit.selection.activeSubDocument;
var position = richEdit.selection.active;
var tables = subDocument.tables.find(position);
for(var i = tables.length - 1, table; table = tables[i]; i--)
    table.delete();

mergeCells(startPosition, endPosition) Method

Merges all cells in the specified range.

Declaration

ts
mergeCells(
    startPosition: TableCellPosition,
    endPosition: TableCellPosition
): void

Parameters

NameTypeDescription
startPositionTableCellPosition

The position of the first cell in the range.

| | endPosition | TableCellPosition |

The position of the last cell in the range.

|

Remarks

A TableCellPosition object stores a cell’s position in the table. Pass two cell positions to the mergeCells method to merge all cells in the specified range. The resulting cell has the same appearance settings as the first cell in the range.

The following code snippet merges 6 cells:

js
const subDocument = richEdit.selection.activeSubDocument;
const table = subDocument.tables.getByIndex(0);
const startCell = { rowIndex: 0, cellIndex: 0 };
const endCell = { rowIndex: 2, cellIndex: 1 };
table.mergeCells(startCell, endCell);