menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfDataForm - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfDataForm

    Inheritance
    System.Object
    SfBaseComponent
    SfDataForm
    Inherited Members
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.OnInitializedAsync()
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    Namespace: Syncfusion.Blazor.DataForm
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class SfDataForm : SfBaseComponent, IForm

    Constructors

    SfDataForm()

    Declaration
    public SfDataForm()

    Properties

    AutoComplete

    Gets or sets the value of the autocomplete attribute of the SfDataForm component.

    Declaration
    public string AutoComplete { get; set; }
    Property Value
    Type Description
    System.String

    Accept the System.String value.

    Remarks

    on, the browser is allowed to automatically complete the input field based on the user's previous inputs. off, the browser is not allowed to automatically complete the input field. The autocomplete feature in the browser can be helpful in providing suggestions to users while they fill out the components. However, in certain scenarios, it might be necessary to disable this feature for security or privacy reasons.

    ButtonsAlignment

    Gets or sets the alignment of the SfDataForm component buttons.

    Declaration
    public FormButtonsAlignment ButtonsAlignment { get; set; }
    Property Value
    Type Description
    FormButtonsAlignment

    One of the FormButtonsAlignment enumeration value, indicating the horizontal alignment of form buttons.

    Remarks

    The default value is Left. The alignment options for form buttons are:

    • Left: Aligns the form buttons to the left side of the form.
    • Center: Centers the form buttons within the form.
    • Right: Aligns the form buttons to the right side of the form.
    • Stretch: The form buttons stretch to the full width of the form. Use this property to customize the horizontal alignment of the form buttons within an instance of the SfDataForm component.

    ColumnCount

    Gets or sets the number of columns in a form layout.

    Declaration
    public int ColumnCount { get; set; }
    Property Value
    Type Description
    System.Int32

    An integer that represents the number of columns in a form layout.

    Remarks

    The ColumnCount property specifies the number of columns in a form layout. It is typically used in UI design to control the layout structure. A higher value will result in more columns and a more complex layout.

    ColumnSpacing

    Gets or sets the spacing between columns in a form grid layout.

    Declaration
    public string ColumnSpacing { get; set; }
    Property Value
    Type Description
    System.String

    Accept the System.String value.

    Remarks

    The spacing between columns, expressed in a CSS-compatible unit (e.g., pixels, em, rem). Use this property to control the horizontal spacing between columns in the form layout. Adjusting this property can impact the overall visual appearance of the form.

    EditContext

    Gets or sets the EditContext of the form. The user should specify either EditContext, or Model.

    Declaration
    public EditContext EditContext { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.Forms.EditContext

    Microsoft.AspNetCore.Components.Forms.EditContext

    Remarks

    If using this EditContext, do not also supply Model, since the model value will be taken from the Model property.

    EnableFloatingLabel

    Gets or sets a value indicating whether the Floating Label feature is enabled for all form fields in the SfDataForm component.

    Declaration
    public bool EnableFloatingLabel { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if the Floating Label feature is enabled; otherwise, false. The default value is false.

    Remarks

    When set to true, the Floating Label feature is enabled, causing labels to move to a floating position above the field when it is focused or contains user input, and it is enabled globally.

    When set to false, the existing behavior of label in the form fields is maintained, and the Floating Label feature is disabled globally.

    Note: Floating label functionality does not work when the label position is set to left. To enable the Floating Label feature, ensure that the label position is set to top.

    The value from the LabelText property or System.ComponentModel.DataAnnotations.DisplayAttribute.Name property (Display name attribute) will be used as the Floating label text. When both properties are specified, the System.ComponentModel.DataAnnotations.DisplayAttribute.Name property takes precedence.

    FormButtons

    Gets or sets the template for customizing form buttons and adding a specified number of buttons to the SfDataForm component.

    Declaration
    public FormButtons FormButtons { get; set; }
    Property Value
    Type Description
    FormButtons

    The property allows you to provide custom HTML or components for form buttons.

    Remarks

    Use this property to customize the appearance and behavior of form buttons and to add a specified number of buttons to the form, such as submit or reset buttons. This is particularly useful for scenarios where you need to create dynamic forms with multiple buttons for various actions.

    FormName

    Gets or sets the form handler name. This is used to identify the form when posting data to a server-side endpoint. It is not used during interactive rendering.

    Declaration
    public string FormName { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the name of the form. This is typically used in scenarios where the form needs to be submitted to a server or handled by a specific form handler endpoint.

    Remarks

    The FormName property is essential for associating the form with a specific server-side handler or endpoint, particularly when multiple forms exist on the same page or when using form-specific logic for submission. It does not affect the form's visual rendering or interaction on the client side.

    FormTemplate

    Gets or sets the template for the form items to provide the custom components.

    Declaration
    public FormTemplate FormTemplate { get; set; }
    Property Value
    Type Description
    FormTemplate

    The template content. The default value is null.

    FormValidator

    Gets or sets the validation type for the form items.

    Declaration
    public FormValidator FormValidator { get; set; }
    Property Value
    Type Description
    FormValidator

    The template content that allows you to provide DataAnnotations or FluentValidation.

    ID

    Gets or sets the ID of the form.

    Declaration
    public string ID { get; set; }
    Property Value
    Type Description
    System.String

    Accept the ID System.String value for the SfDataForm component.

    Remarks

    The "ID" property is typically used to uniquely identify an object within a application. It should be unique and immutable once set. When creating or modifying an object, ensure that the "ID" is unique and meaningful for efficient object management and retrieval.

    LabelPosition

    Gets or sets the position of labels in the form field items.

    Declaration
    public Nullable<FormLabelPosition> LabelPosition { get; set; }
    Property Value
    Type Description
    System.Nullable<FormLabelPosition>

    One of the FormLabelPosition enumeration value.

    Remarks

    The position options are: Top : The labels are positioned above the form fields. Left : The labels are positioned to the left of the form fields. Use this property to control where labels are positioned in the form layout. You can choose from various positions such as "Top," or "Left". The LabelPosition property determines the layout of labels within a form. It allows you to control whether labels should be placed to the left, or to the top of form fields.

    LabelPositionHasDelegate

    Declaration
    protected bool LabelPositionHasDelegate { get; set; }
    Property Value
    Type
    System.Boolean

    Model

    Gets or sets the data model that represents the form's data.

    Declaration
    public object Model { get; set; }
    Property Value
    Type Description
    System.Object

    The data model object containing the form's data.

    Remarks

    This property represents the data model that corresponds to the form's fields. The form's fields will be bound to properties of this model object.

    OnInvalidSubmit

    Fires when the form is submitted with invalid EditContext.

    Declaration
    public EventCallback<EditContext> OnInvalidSubmit { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<Microsoft.AspNetCore.Components.Forms.EditContext>

    OnSubmit

    Gets or sets the event callback that will be invoked when the SfDataForm component is submitted.

    Declaration
    public EventCallback<EditContext> OnSubmit { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<Microsoft.AspNetCore.Components.Forms.EditContext>

    An EventCallback that represents the event handler for form submission.

    Remarks

    The OnSubmit event callback is invoked when a form is submitted. You can use this event handler to perform custom actions when the form is submitted, such as validation, data processing, or navigation. The callback may receive additional data depending on the specific form and context.

    OnUpdate

    Gets or sets the event callback that will be invoked upon editing a field in the SfDataForm component. The changed field name and newly updated model are available through the FormUpdateEventArgs event context.

    Declaration
    public EventCallback<FormUpdateEventArgs> OnUpdate { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<FormUpdateEventArgs>

    An Microsoft.AspNetCore.Components.EventCallback<> that represents the event handler for form updates.

    Remarks

    The OnUpdate event callback is triggered when the form is updated. It allows you to respond to changes in the form data, perform validation, and execute custom logic in response to updates. The callback may receive additional data in the form of a FormUpdateEventArgs object, providing details about the update.

    OnValidSubmit

    Fires when the form is submitted with valid EditContext.

    Declaration
    public EventCallback<EditContext> OnValidSubmit { get; set; }
    Property Value
    Type
    Microsoft.AspNetCore.Components.EventCallback<Microsoft.AspNetCore.Components.Forms.EditContext>

    ValidationDisplayMode

    Gets or sets the way the validation errors should be displayed in the SfDataForm component.

    Declaration
    public FormValidationDisplay ValidationDisplayMode { get; set; }
    Property Value
    Type Description
    FormValidationDisplay

    One of the FormValidationDisplay enumeration value.

    Remarks

    The display options are: Inline : The validation message is displayed below the form field. ToolTip : The validation message is displayed in a tooltip. None : No validation messages are rendered. Useful when user want to have only ValidationSummary to show error messages. The ValidationDisplayMode property allows you to control how validation error messages are presented within a SfDataForm component. You can choose to display them inline or as tooltips based on the selected option from the enumeration.

    Width

    Gets or sets the width of a SfDataForm component.

    Declaration
    public string Width { get; set; }
    Property Value
    Type Description
    System.String

    A string value representing the width of the form element. You can use CSS-compatible units (e.g., pixels, em, rem) to specify the width.

    Remarks

    Use this property to control the width of the SfDataForm component. The width value determines how much horizontal space the element occupies within the layout.

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    GetAutogeneratedItems(List<PropertyInfo>)

    Declaration
    protected void GetAutogeneratedItems(List<PropertyInfo> properties)
    Parameters
    Type Name Description
    System.Collections.Generic.List<System.Reflection.PropertyInfo> properties

    IsValid()

    Checks whether the form data is valid based on defined validation rules.

    Declaration
    public bool IsValid()
    Returns
    Type Description
    System.Boolean

    true if the form data is valid; otherwise, false.

    Remarks

    This method evaluates the form data against defined validation rules to determine its validity. You should call this method to check if the data entered by the user is valid before further processing.

    OnAfterRenderAsync(Boolean)

    Method invoked after each time the component has been rendered.

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    Type Name Description
    System.Boolean firstRender

    Set to true for the first time component rendering; otherwise gets false.

    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing any asynchronous operation.

    Overrides
    SfBaseComponent.OnAfterRenderAsync(Boolean)

    OnInitialized()

    Declaration
    protected override void OnInitialized()

    OnParametersSetAsync()

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type
    System.Threading.Tasks.Task

    Refresh()

    Refreshes the form, updating its contents and resetting the validation state.

    Declaration
    public void Refresh()
    Remarks

    This method updates the form to reflect any changes in the data model or configuration. It also resets the validation state, clearing any existing validation error messages. Call this method to ensure the form is up-to-date and ready for user interaction.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved