Interface IDateRangePicker
Defines the contract for DateRangePicker component operations and state management.
Namespace: Syncfusion.Blazor.Calendars
Assembly: Syncfusion.Blazor.dll
Syntax
public interface IDateRangePicker
Remarks
This interface provides essential methods for updating child properties and managing the component's state lifecycle. It is implemented by DateRangePicker components to ensure consistent behavior across different implementations.
Examples
Usage example for implementing IDateRangePicker interface:
public class CustomDateRangePicker : IDateRangePicker
{
public void UpdateChildProperties(object presetValue)
{
// Update child component properties based on preset value
}
public async Task CallStateHasChangedAsync()
{
// Trigger component state refresh
await InvokeAsync(StateHasChanged);
}
}
Methods
CallStateHasChangedAsync()
Asynchronously invokes the StateHasChanged method to notify the component that its state has changed and requires re-rendering.
Declaration
Task CallStateHasChangedAsync()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task | A System.Threading.Tasks.Task representing the asynchronous state change operation. |
Remarks
This method is used to trigger a component re-render when the component's state has been modified programmatically. It ensures that any changes to the component's properties or internal state are reflected in the UI. The method should be called after making changes that affect the visual representation of the component.
Examples
Example of calling state change asynchronously:
// After updating component state
await dateRangePicker.CallStateHasChangedAsync();
UpdateChildProperties(Object)
Updates the child properties of the DateRangePicker component based on the specified preset configuration.
Declaration
void UpdateChildProperties(object presetValue)
Parameters
Type | Name | Description |
---|---|---|
System.Object | presetValue | The preset configuration object containing the values to be applied to child properties. This can be a preset range configuration or custom range settings. |
Remarks
This method is typically called when a preset range is selected or when child component properties need to be synchronized with new configuration values. The preset value can contain date ranges, formatting options, or other configuration settings that should be propagated to child components.
Examples
Example of updating child properties with preset values:
var presetConfig = new
{
StartDate = DateTime.Today.AddDays(-7),
EndDate = DateTime.Today,
Label = "Last 7 Days"
};
dateRangePicker.UpdateChildProperties(presetConfig);