-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
403 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,66 @@ | ||
# Form Renderer Component Reference | ||
|
||
The Form Renderer component is used to render forms in that designed by the `FormEditor` component. | ||
The Form Renderer component is used to render forms designed by the `FormEditor` component. | ||
You can specify either the `FormId` or `FormJson` property to render a form. | ||
|
||
## FormRenderer Properties | ||
- `FormId`: The ID of the form to render. It fetches form data from the API based on the ID. | ||
- `FormJson`: The JSON data of the form to render. You can pass the JSON data of the form directly to the component. | ||
- `IsLoadingForm`: A boolean value that indicates whether the form is loading and rendering. | ||
|
||
- **`FormId`**: The ID of the form to render. This fetches form data from the API based on the ID. | ||
- **`FormJson`**: The JSON data of the form to render. This allows you to pass the JSON data of the form directly to the component. | ||
- **`IsLoadingForm`**: A boolean value indicating whether the form is currently loading and rendering. | ||
|
||
## FormRenderer Events | ||
- `IsLoadingFormChanged`: An event that is triggered when the `IsLoadingForm` property changes. You can use this event to perform additional actions when the form is loading. | ||
- `FormLoaded`: An event that is triggered when the form is loaded and rendered. You can use this event to perform additional actions when the form is loaded. | ||
|
||
## FormRenderer public methods | ||
- `LoadFormFromIdAsync(string formId)`: A method that loads the form data from the API based on the form ID. | ||
- `LoadFormFromJsonAsync(string formJson)`: A method that loads the form data from the JSON data. | ||
- `GetFormAsJsonAsync()`: A method that returns the JSON data of the rendered form. | ||
- **`IsLoadingFormChanged`**: An event triggered when the `IsLoadingForm` property changes. Use this event to perform additional actions when the form is loading. | ||
- **`FormLoaded`**: An event triggered when the form is fully loaded and rendered. Use this event to perform additional actions when the form is loaded. | ||
|
||
## FormRenderer Public Methods | ||
|
||
- **`LoadFormFromIdAsync(string formId)`**: Loads the form data from the API based on the form ID. | ||
- **`LoadFormFromJsonAsync(string formJson)`**: Loads the form data from the provided JSON data. | ||
- **`GetFormAsJsonAsync()`**: Returns the JSON data of the rendered form. | ||
|
||
## Examples | ||
## Render a form using FormId or FormJson properties | ||
|
||
### Render a form using FormId or FormJson properties | ||
|
||
Render a form using the `FormId` property: | ||
|
||
```html | ||
<FormRenderer FormId="1" /> | ||
``` | ||
|
||
Render a form using the `FormJson` property: | ||
|
||
```html | ||
<FormRenderer FormJson="@formJson" /> | ||
``` | ||
|
||
## Render a form dynamically using methods | ||
### Render a form dynamically using methods | ||
|
||
```html | ||
<FormRenderer @ref="formRendererRef" /> | ||
|
||
<RadzenTextBox @bind-Value="_formId" /> | ||
<RadzenButton Text="Load Form" Click="@LoadForm" /> | ||
``` | ||
|
||
```csharp | ||
@code { | ||
private FormRenderer? formRendererRef; | ||
private string? _formId; | ||
|
||
private async Task LoadForm() | ||
{ | ||
if (formRendererRef is null || string.IsNullOrEmpty(_formId)) | ||
{ | ||
return; | ||
} | ||
await formRenderer.LoadFormFromIdAsync(_formId); | ||
|
||
await formRendererRef.LoadFormFromIdAsync(_formId); | ||
} | ||
} | ||
``` | ||
|
||
In these examples, the `FormRenderer` component can be used to dynamically load forms based on either a form ID or JSON data. | ||
The component also provides events and methods to manage the loading state and retrieve the rendered form data as JSON. |
Oops, something went wrong.