Your search did not match any results.
Form

Overview

Documentation

The Form component allows you to visually represent and edit data stored in an object. The component binds each layout item to a specific field in an existing data object. To display a simple form, you can assign the required object to the formData property. With the Form component, you can specify the location of labels against corresponding editors and number of columns used in the form layout. Optionally, the component can determine the column count based on current form width (adaptive rendering).

Copy to CodePen
Apply
Reset
$(function(){ var form = $("#form").dxForm({ formData: companies[0], readOnly: false, showColonAfterLabel: true, labelLocation: "top", minColWidth: 300, colCount: 2 }).dxForm("instance"); $("#select-company").dxSelectBox({ displayExpr: "Name", dataSource: companies, value: companies[0], onValueChanged: function(data) { form.option("formData", data.value); } }); $("#label-location").dxSelectBox({ items: ["left", "top"], value: "top", onValueChanged: function(data) { form.option("labelLocation", data.value); } }); $("#columns-count").dxSelectBox({ items: ["auto", 1, 2, 3], value: 2, onValueChanged: function(data) { form.option("colCount", data.value); } }); $("#min-column-width").dxSelectBox({ items: [150, 200, 300], value: 300, onValueChanged: function(data) { form.option("minColWidth", data.value); } }); $("#width").dxNumberBox({ value: undefined, max: 550, onValueChanged: function(data) { form.option("width", data.value); } }); $("#read-only").dxCheckBox({ text: "readOnly", value: false, onValueChanged: function(data) { form.option("readOnly", data.value); } }); $("#show-colon").dxCheckBox({ text: "showColonAfterLabel", value: true, onValueChanged: function(data) { form.option("showColonAfterLabel", data.value); } }); });
<!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.5.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.6/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/20.2.6/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/20.2.6/js/dx.all.js"></script> <script src="data.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 id="form-demo"> <div class="widget-container"> <div>Select company:</div> <div id="select-company"></div> <div id="form"></div> </div> <div class="options"> <div class="caption">Options</div> <div class="option"> <span>Label location:</span> <div id="label-location"></div> </div> <div class="option"> <span>Columns count:</span> <div id="columns-count"></div> </div> <div class="option"> <span>Min column width:</span> <div id="min-column-width"></div> </div> <div class="option"> <span>Form width:</span> <div id="width"></div> </div> <div class="option"> <div id="read-only"></div> </div> <div class="option"> <div id="show-colon"></div> </div> </div> </div> </div> </body> </html>
.widget-container { margin-right: 320px; padding: 20px; max-width: 550px; min-width: 300px; } #form { margin-top: 25px; } .options { padding: 20px; position: absolute; bottom: 0; right: 0; width: 260px; top: 0; background-color: rgba(191, 191, 191, 0.15); } .caption { font-size: 18px; font-weight: 500; } .option { margin-top: 10px; }
var companies = [{ "ID": 1, "Name": "Super Mart of the West", "Address": "702 SW 8th Street", "City": "Bentonville", "State": "Arkansas", "ZipCode": 72716, "Phone": "(800) 555-2797", "Fax": "(800) 555-2171", "Website": "http://www.nowebsitesupermart.com" }, { "ID": 2, "Name": "Electronics Depot", "Address": "2455 Paces Ferry Road NW", "City": "Atlanta", "State": "Georgia", "ZipCode": 30339, "Phone": "(800) 595-3232", "Fax": "(800) 595-3231", "Website": "http://www.nowebsitedepot.com" }, { "ID": 3, "Name": "K&S Music", "Address": "1000 Nicllet Mall", "City": "Minneapolis", "State": "Minnesota", "ZipCode": 55403, "Phone": "(612) 304-6073", "Fax": "(612) 304-6074", "Website": "http://www.nowebsitemusic.com" }, { "ID": 4, "Name": "Tom's Club", "Address": "999 Lake Drive", "City": "Issaquah", "State": "Washington", "ZipCode": 98027, "Phone": "(800) 955-2292", "Fax": "(800) 955-2293", "Website": "http://www.nowebsitetomsclub.com" }];