Your search did not match any results.
Custom Text Editor Buttons

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.

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 widget 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 widget. String and object declarations can be used in the same array.

The USD/EUR rate is taken from https://www.x-rates.com/ and is relevant on 31 March 2019
Copy to CodePen
Apply
Reset
$(function(){ var passwordEditor = $("#password").dxTextBox({ placeholder: "password", mode: "password", value: "password", stylingMode: "filled", buttons: [{ name: "password", location: "after", options: { icon: "../../../../images/icons/eye.png", type: "default", onClick: function() { passwordEditor.option("mode", passwordEditor.option("mode") === "text" ? "password" : "text"); } } }] }).dxTextBox("instance"); var currencyEditor = $("#multicurrency").dxNumberBox({ value: 14500.55, format: "$ #.##", showClearButton: true, showSpinButtons: true, buttons: [{ name: "currency", location: "after", options: { text: "€", stylingMode: "text", width: 32, elementAttr: { class: "currency" }, onClick: function(e) { if(e.component.option("text") === "$") { e.component.option("text", "€"); currencyEditor.option("format", "$ #.##"); currencyEditor.option("value", currencyEditor.option("value") / 0.891); } else { e.component.option("text", "$"); currencyEditor.option("format", "€ #.##"); currencyEditor.option("value", currencyEditor.option("value") * 0.891); } } } }, "clear", "spins"] }).dxNumberBox("instance"); var millisecondsInDay = 24 * 60 * 60 * 1000; var dateEditor = $("#advanced-datebox").dxDateBox({ value: new Date().getTime(), stylingMode: "outlined", buttons: [{ name: "today", location: "before", options: { text: "Today", onClick: function() { dateEditor.option("value", new Date().getTime()); } } }, { name: "prevDate", location: "before", options: { icon: "spinprev", stylingMode: "text", onClick: function() { var currentDate = dateEditor.option("value"); dateEditor.option("value", currentDate - millisecondsInDay); } } }, { name: "nextDate", location: "after", options: { icon: "spinnext", stylingMode: "text", onClick: function() { var currentDate = dateEditor.option("value"); dateEditor.option("value", currentDate + millisecondsInDay); } } }, "dropDown"] }).dxDateBox("instance"); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="https://cdnjs.cloudflare.com/ajax/libs/cldrjs/0.4.4/cldr.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/cldrjs/0.4.4/cldr/event.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/cldrjs/0.4.4/cldr/supplemental.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/cldrjs/0.4.4/cldr/unresolved.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/globalize/1.1.1/globalize.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/globalize/1.1.1/globalize/message.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/globalize/1.1.1/globalize/number.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/globalize/1.1.1/globalize/currency.min.js"></script> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/globalize/1.1.1/globalize/date.min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.2.4/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/19.2.4/js/dx.all.js"></script> <link rel="stylesheet" type="text/css" href="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div class="dx-fieldset"> <div class="dx-field"> <div class="dx-field-label">Password TextBox</div> <div class="dx-field-value"> <div id="password"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Multi-currency NumberBox</div> <div class="dx-field-value"> <div id="multicurrency"></div> </div> </div> <div class="dx-field"> <div class="dx-field-label">Advanced DateBox</div> <div class="dx-field-value"> <div id="advanced-datebox"></div> </div> </div> </div> </div> </body> </html>
.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; }