Table Class
A table in a sub-document.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v24.1.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public class Table :
DocumentElementBase,
ITableProperties,
ITableProperties
Related API Members
The following members return Table objects:
Remarks
The Tables property returns the collection of tables in the sub-document. A table consists of cells combined into rows.
Tip
Refer to the following topic for examples on how to manage tables in code: Tables in Blazor Rich Text Editor.
The following code sample creates a table and populates it with data:
<DxRichEdit @ref="richEdit" />
@code {
DxRichEdit richEdit;
protected override async Task OnAfterRenderAsync(bool firstRender) {
if (firstRender)
try {
await InitializeDocument();
}
catch (TaskCanceledException) { }
await base.OnAfterRenderAsync(firstRender);
}
async Task InitializeDocument() {
/* Surround the code that contains an asynchronous operation with a try-catch block to handle
the OperationCanceledException. This exception is thrown when an asynchronous operation is canceled. */
try {
var columnCount = 4;
var rowCount = 5;
richEdit.DocumentAPI.BeginUpdate();
Table firstTable = await richEdit.DocumentAPI.Tables.CreateAsync(0, columnCount, rowCount);
for (int i = firstTable.Rows.Count - 1; i >= 0 ; i--)
for (int j = firstTable.Rows[i].Cells.Count - 1; j >= 0 ; j--) {
var cellPosition = myTable.Rows[i].Cells[j].Interval.Start;
await richEdit.DocumentAPI.AddTextAsync(cellPosition, "sample text");
}
richEdit.DocumentAPI.EndUpdate();
}
catch (OperationCanceledException e) {
Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
}
}
}
Dialogs
The Rich Text Editor includes the following dialogs that allow users to create, edit, and delete tables.
The Insert Table Dialog
The Rich Text Editor invokes this dialog when a user selects the Insert → Table ribbon command. The Insert Table dialog allows users to create a table with a specified number of rows and columns.
The Insert Cells Dialog
The Rich Text Editor invokes this dialog when a user selects the Insert → Insert Cells… context menu command. The Insert Cells dialog allows users to insert a cell, column, or row to a table.
The Split Cells Dialog
The Rich Text Editor invokes this dialog when a user selects the Layout → Split Cells ribbon command or Split Cells… context menu command. The Split Cells dialog allows users to split selected cells into multiple new cells.
The Delete Cells Dialog
The Rich Text Editor invokes this dialog when a user selects the Layout → Delete → Delete Cells… ribbon command or Delete Cells… context menu command. The Delete Cells dialog allows users to delete a table cell, column, or row.