blazor-devexpress-dot-blazor-dot-dxdateedit-1-885cd5fa.md
Allows you to add command buttons to the Date Edit.
Namespace : DevExpress.Blazor
Assembly : DevExpress.Blazor.v25.2.dll
NuGet Package : DevExpress.Blazor
[Parameter]
public RenderFragment Buttons { get; set; }
| Type | Description |
|---|---|
| RenderFragment |
A collection of buttons (UI fragments).
|
The Date Edit component has the built-in button that invokes a drop-down calendar. You can use the ShowDropDownButton property to hide this button.
You can also add custom command buttons to the Date Edit:
Add the <Buttons></Buttons> tag to the component’s markup to define the Buttons collection.
Fill the Buttons collection. The following buttons are available:
Set up button properties to customize the buttons:
Buttons are displayed in an editor in the following order:
The following code adds date increment/decrement buttons to the Date Edit.
<DxDateEdit @bind-Date="@DateTimeValue">
<Buttons>
<DxEditorButton IconCssClass="editor-icon editor-icon-chevron-left-small"
Tooltip="Previous day"
Position="@EditorButtonPosition.Left"
Click="@(_ => OnChangeDayButtonClick(false))" />
<DxEditorButton IconCssClass="editor-icon editor-icon-chevron-right-small"
Tooltip="Next day"
Position="@EditorButtonPosition.Right"
Click="@(_ => OnChangeDayButtonClick(true))" />
</Buttons>
</DxDateEdit>
@code{
DateTime DateTimeValue { get; set; } = DateTime.Today;
void OnChangeDayButtonClick(bool isAdd) {
DateTimeValue = DateTimeValue.AddDays(isAdd ? 1 : -1);
}
}
Run Demo: Editors - Command Buttons
We do not recommend that you use conditional render within the <Buttons></Buttons tag. This may cause an incorrect button order. The following example demonstrates a case when the Button1 may change its position.
<Buttons>
@if(condition) {
<DxEditorButton Text="Button1"/>
}
<DxEditorButton Text="Button2"/>
<DxEditorButton Text="Button3"/>
</Buttons>
If you need to hide a button, set the Visible property to false.
See Also