Back to Devexpress

Table.ParentCell Property

blazor-devexpress-dot-blazor-dot-richedit-dot-table-c82daddb.md

latest2.4 KB
Original Source

Table.ParentCell Property

Returns the cell that contains the current table.

Namespace : DevExpress.Blazor.RichEdit

Assembly : DevExpress.Blazor.RichEdit.v25.2.dll

NuGet Package : DevExpress.Blazor.RichEdit

Declaration

csharp
public TableCell ParentCell { get; }

Property Value

TypeDescription
TableCell

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

|

Remarks

The Rich Text Editor component allows users to place tables within tables. Use the ParentCell property to obtain the cell that contains the current table. If the table is not nested, the ParentCell property returns null.

The following example applies the Grid Table 4 Accent 4 style to all nested tables:

razor
<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 {
            richEdit.DocumentAPI.BeginUpdate();
            var Tables = await richEdit.DocumentAPI.Tables.GetAllAsync();
            for (int i=0; i < Tables.Count; i++) {
                if (Tables[i].ParentCell != null)
                    await Tables[i].ChangePropertiesAsync(properties => {
                        properties.StyleName = TableStyleName.GridTable4Accent4;
                    });
            }
            richEdit.DocumentAPI.EndUpdate();
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
    }
}

See Also

Tables in Blazor Rich Text Editor

Table Class

Table Members

DevExpress.Blazor.RichEdit Namespace