Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Fields.ToggleViewAsync(Field, CancellationToken) Method

Changes the display mode of a field.

Namespace: DevExpress.Blazor.RichEdit

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

NuGet Package: DevExpress.Blazor.RichEdit

#Declaration

C#
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.

Razor
<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