Skip to main content

Fields.ToggleViewAsync(Field, CancellationToken) Method

Changes the display mode of a field.

Namespace: DevExpress.Blazor.RichEdit

Assembly: DevExpress.Blazor.RichEdit.v24.1.dll

NuGet Package: DevExpress.Blazor.RichEdit

Declaration

public ValueTask ToggleViewAsync(
    Field field,
    CancellationToken cancellationToken = default(CancellationToken)
)

Parameters

Name Type Description
field Field

A field.

Optional Parameters

Name Type Default Description
cancellationToken CancellationToken null

An object that propagates a cancellation notification.

Returns

Type Description
ValueTask

A structure that stores an awaitable result of an asynchronous operation.

Remarks

A field has the {Code}Result> structure in the text buffer, for instance, {DATE}11/2/2020>. The Code specifies how the Result should be calculated when the field is updated.

The Rich Text Editor can display a field as a code or result. A field’s IsShowCode property allows you to get whether the field’s code or result is visible. Call the ToggleViewAsync(Field) method to change the view mode of a field.

<DxRichEdit @ref="@richEdit" />

@code {
    DxRichEdit richEdit;
    Document documentAPI;
    @* ... *@
    /* 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 {
            documentAPI = richEdit.DocumentAPI;
            @* ... *@
            // Gets the first field in the main sub-document
            Field myField = await documentAPI.Fields.GetAsync(0);
            // If the Rich Text Editor displays the first field as a code, displays the field as a result
            if (myField.IsShowCode)
                await documentAPI.Fields.ToggleViewAsync(myField);
                @* ... *@
        }
        catch (OperationCanceledException e) {
            Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {e.Message}");
        }
}

Use the following methods to change the display mode of every field in a sub-document or in all sub-documents:

See Also