Your search did not match any results.

Editors - Custom Text Editor Buttons

Text editors have built-in action buttons that allow users to open a drop-down menu, increase, decrease, or nullify the value, and perform other actions. To add custom action buttons for different scenarios, use the buttons[] array.

The USD/EUR rate is taken from www.wikipedia.org and is relevant on 14 April 2021
Backend API
<div class="dx-fieldset"> <div class="dx-field"> <div class="dx-field-label">Password TextBox</div> <div class="dx-field-value"> @(Html.DevExtreme().TextBox() .ID("password") .Value("password") .InputAttr("aria-label", "Password") .Placeholder("password") .Mode(TextBoxMode.Password) .StylingMode(EditorStylingMode.Filled) .Buttons(buttons => { buttons.Add() .Name("password") .Location(TextEditorButtonLocation.After) .Widget(w => w.Button() .StylingMode(ButtonStylingMode.Text) .Icon("eyeopen") .OnClick("changePasswordMode")); }) ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Multi-currency NumberBox</div> <div class="dx-field-value"> @(Html.DevExtreme().NumberBox() .ID("multicurrency") .Value(14500.55) .Format("$ #.##") .ShowClearButton(true) .InputAttr("aria-label", "Multi Currency") .ShowSpinButtons(true) .Buttons(buttons => { buttons.Add() .Name("currency") .Location(TextEditorButtonLocation.After) .Widget(w => w.Button() .Text("€") .StylingMode(ButtonStylingMode.Text) .Width(32) .ElementAttr("class", "currency") .OnClick("changeCurrency")); buttons.Add() .Name("clear"); buttons.Add() .Name("spins"); }) ) </div> </div> <div class="dx-field"> <div class="dx-field-label">Advanced DateBox</div> <div class="dx-field-value"> @(Html.DevExtreme().DateBox() .ID("advanced-datebox") .InputAttr("aria-label", "Date") .Value(new JS("new Date().getTime()")) .StylingMode(EditorStylingMode.Outlined) .OnInitialized("dateOnInitialized") .Buttons(buttons => { buttons.Add() .Name("today") .Location(TextEditorButtonLocation.Before) .Widget(w => w.Button() .Text("Today") .StylingMode(ButtonStylingMode.Text) .OnClick("today")); buttons.Add() .Name("prevDate") .Location(TextEditorButtonLocation.Before) .Widget(w => w.Button() .Icon("spinprev") .StylingMode(ButtonStylingMode.Text) .OnClick("prevDate")); buttons.Add() .Name("nextDate") .Location(TextEditorButtonLocation.After) .Widget(w => w.Button() .Icon("spinnext") .StylingMode(ButtonStylingMode.Text) .OnClick("nextDate")); buttons.Add() .Name("dropDown"); }) ) </div> </div> </div> <script> var millisecondsInDay = 24 * 60 * 60 * 1000; function changePasswordMode() { var passwordEditor = $("#password").dxTextBox("instance"); passwordEditor.option("mode", passwordEditor.option("mode") === "text" ? "password" : "text"); } function changeCurrency(e) { var currencyEditor = $("#multicurrency").dxNumberBox("instance"); if(e.component.option("text") === "$") { e.component.option("text", "€"); currencyEditor.option("format", "$ #.##"); currencyEditor.option("value", currencyEditor.option("value") / 0.836); } else { e.component.option("text", "$"); currencyEditor.option("format", "€ #.##"); currencyEditor.option("value", currencyEditor.option("value") * 0.836); } } var dateEditor; function dateOnInitialized(e) { dateEditor = e.component; } function today() { dateEditor.option("value", new Date().getTime()); } function prevDate() { dateEditor.option("value", dateEditor.option("value") - millisecondsInDay); } function nextDate() { dateEditor.option("value", dateEditor.option("value") + millisecondsInDay); } </script>
using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using DevExtreme.AspNet.Mvc; using Newtonsoft.Json; using DevExtreme.AspNet.Data; using DevExtreme.NETCore.Demos.Models; using DevExtreme.NETCore.Demos.Models.SampleData; using DevExtreme.NETCore.Demos.ViewModels; using DevExtreme.NETCore.Demos.Models.DataGrid; // For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 namespace DevExtreme.NETCore.Demos.Controllers { public class CommonController : Controller { public ActionResult CustomTextEditorButtons() { return View(); } } }
.dx-fieldset { min-height: 560px; width: 560px; margin: 0 auto; } .currency { min-width: 32px; } .dx-button.currency .dx-button-content { font-size: 120%; padding-left: 5px; padding-right: 5px; }

Each object in the buttons[] array should have the name field—the button's identifier. In addition, specify the button's location relative to the input text field and options of the Button component used as the action button.

The buttons[] array also accepts string values—the names of built-in buttons. Declare them in the order the buttons should have in the component. String and object declarations can be used in the same array.