aspnetcore-js-devexpress-dot-richedit-a79e6d55.md
Defines a table in the document.
export class Table extends TableElementBase
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();
Specifies whether the table automatically adjusts its width to fit content.
get autoFit(): boolean
set autoFit(value: boolean)
| Type | Description |
|---|---|
| boolean |
true if the table automatically adjusts its width to fit content; otherwise, false.
|
A table can automatically adjust its width to fit content. Use the autoFit property to identify whether size adjustment is enabled.
Specifies the table’s background color.
get backgroundColor(): string
set backgroundColor(value: string)
| Type | Description |
|---|---|
| string |
The table’s background color.
|
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).
Specifies the table’s border settings.
get borders(): TableBorders
set borders(value: ITableBorders)
| Type | Description |
|---|---|
| TableBorders |
Table border settings.
|
Specify the borders property to configure a table’s border settings.
Specifies margin settings of all cells in the table.
get cellMargins(): Margins
set cellMargins(value: IMargins)
| Type | Description |
|---|---|
| Margins |
An object that contains margin settings.
|
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.
Specifies the horizontal alignment of table content.
get contentHorizontalAlignment(): TableContentHorizontalAlignment | null
set contentHorizontalAlignment(value: TableContentHorizontalAlignment)
| Type | Description |
|---|---|
| TableContentHorizontalAlignment |
An enumeration value.
|
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.
Specifies the vertical alignment of table content.
get contentVerticalAlignment(): TableContentVerticalAlignment | null
set contentVerticalAlignment(value: TableContentVerticalAlignment)
| Type | Description |
|---|---|
| TableContentVerticalAlignment |
An enumeration value.
|
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.
Gets an index of the table.
get index(): number
| Type | Description |
|---|---|
| number |
The table’s index.
|
Use the index to access the corresponding table by the TableCollection.getByIndex method.
Gets the text buffer interval occupied by the current table element.
get interval(): Interval
| Type | Description |
|---|---|
| Interval |
An object that contains the interval settings.
|
Returns the cell that contains the current table.
get parentCell(): TableCell | null
| Type | Description |
|---|---|
| TableCell |
The cell that contains the current table; null if the table is not nested.
|
Provides access to a collection of table rows.
get rows(): TableRowCollection
| Type | Description |
|---|---|
| TableRowCollection |
An array of TableRow objects that store information about individual table rows.
|
Specifies the table style name.
get styleName(): string
set styleName(value: string)
| Type | Description |
|---|---|
| string |
The table style name.
|
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.
Specifies style options applied to the table.
get tableStyleOptions(): TableStyleOptions
set tableStyleOptions(value: TableStyleOptions)
| Type | Description |
|---|---|
| TableStyleOptions |
Table style options.
|
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.
Specifies the table’s width settings.
get width(): TableWidth
set width(value: TableWidth)
| Type | Description |
|---|---|
| TableWidth |
An object that contains width settings.
|
Use the Table.width or TableCell.width property to specify the table or cell width.
Deletes the current table.
delete(): void
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();
Merges all cells in the specified range.
mergeCells(
startPosition: TableCellPosition,
endPosition: TableCellPosition
): void
| Name | Type | Description |
|---|---|---|
| startPosition | TableCellPosition |
The position of the first cell in the range.
| | endPosition | TableCellPosition |
The position of the last cell in the range.
|
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:
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);