Fields.ToggleViewAsync(Field) Method
Changes the display mode of a field.
Namespace: DevExpress.Blazor.RichEdit
Assembly: DevExpress.Blazor.RichEdit.v21.2.dll
NuGet Package: DevExpress.Blazor.RichEdit
Declaration
public ValueTask ToggleViewAsync(
Field field
)
Parameters
Name | Type | Description |
---|---|---|
field | Field | A field. |
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 cancelled. */
try {
documentAPI = richEdit.DocumentAPI;
@* ... *@
// Gets the first field in the main sub-document
Field firstField = await documentAPI.Fields.GetAsync(0);
// If the Rich Text Editor displays the first field as a code, displays the field as a result
if (firstField.IsShowCode)
await documentAPI.Fields.ToggleViewAsync(firstField);
@* ... *@
}
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:
- The ShowAllFieldCodesAsync(Boolean) method displays fields as field codes
- The ShowAllFieldResultsAsync(Boolean) method displays all fields as field results