blazor-404267-components-data-editors-command-buttons.md
DevExpress Blazor editors display built-in command buttons that allow users to open a drop-down, increase/decrease the value, or clear the edit box content.
You can use Show***Button properties to hide these buttons.
You can also customize default command button or add custom buttons to editors. Follow the steps below.
Add the <Buttons></Buttons> tag to the editor’s markup to define the Buttons collection.
Fill the Buttons collection. This collection renders specified buttons in the order they appear in the markup.
Set up button properties to customize the buttons:
Buttons are displayed in an editor in the following order:
Run Demo: Editors - Command Buttons
The following code snippet hides the built-in spin buttons in the Spin editor.
<DxSpinEdit Value="15" ShowSpinButtons="false"></DxSpinEdit>
The following code snippet hides the built-in spin buttons, adds new spin buttons, and specifies their position.
<DxSpinEdit Value="15" ShowSpinButtons="false">
<Buttons>
<DxSpinButtons Position="EditorButtonPosition.Left"/>
</Buttons>
</DxSpinEdit>
The following code snippet adds a custom currency button to the right of the default spin buttons:
@using System.Globalization
<DxSpinEdit @bind-Value="@Price"
Mask="@NumericMask.Currency"
ShowSpinButtons="false">
<Buttons>
<DxSpinButtons />
<DxEditorButton IconCssClass="@($"editor-icon {CurrencyButtonIconClass}")"
Tooltip="Change currency"
Click="@OnChangeCultureInfoButtonClick"
CssClass="dx-demo-editor-width" />
</Buttons>
<ChildContent>
<DxNumericMaskProperties Culture="MaskCultureInfo" />
</ChildContent>
</DxSpinEdit>
@code{
double Price { get; set; }
string CurrencyButtonIconClass { get; set; } = "editor-icon-euro";
CultureInfo MaskCultureInfo { get; set; } = CultureInfoItems[0];
static CultureInfo[] CultureInfoItems { get; set; } = {
CultureInfo.GetCultureInfo("en-US"),
CultureInfo.GetCultureInfo("de-DE")
};
void OnChangeCultureInfoButtonClick() {
var isCurrentCultureUs = MaskCultureInfo.Equals(CultureInfoItems[0]);
MaskCultureInfo = isCurrentCultureUs ? CultureInfoItems[1] : CultureInfoItems[0];
CurrencyButtonIconClass = isCurrentCultureUs ? "editor-icon-dollar" : "editor-icon-euro";
}
}
.dx-demo-editor-width {
max-width: 320px;
width: 100%;
}