Your search did not match any results.
Form

Overview

Documentation
The Form widget allows you to visually represent and edit data stored in an object. The widget 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 option. With the Form widget, you can specify the location of labels against corresponding editors and number of columns used in the form layout. Optionally, the widget can determine the column count based on current form width (adaptive rendering).
Copy to Codepen
Apply
Reset
window.onload = function() { var showColon = ko.observable(true), formData = ko.observable(companies[0]), readOnly = ko.observable(false), labelLocation = ko.observable("top"), minColWidth = ko.observable(300), colCount = ko.observable(2), widthValue = ko.observable(undefined); var viewModel = { formOptions: { formData: formData, readOnly: readOnly, showColonAfterLabel: showColon, labelLocation: labelLocation, minColWidth: minColWidth, colCount: colCount, width: widthValue }, selectCompanyOptions: { displayExpr: "Name", dataSource: companies, value: formData }, readOnlyOptions: { value: readOnly, text: "readOnly" }, showColonOptions: { value: showColon, text: "showColonAfterLabel" }, labelLocationOptions: { items: ["left", "top"], value: labelLocation }, minColWidthOptions: { items: [150, 200, 300], value: minColWidth }, colCountOptions: { items: ["auto", 1, 2, 3], value: colCount }, widthOptions: { max: 550, value: widthValue } }; ko.applyBindings(viewModel, document.getElementById("form-demo")); };
<!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="js/jquery-3.1.0.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.spa.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.light.css" /> <link rel="dx-theme" data-theme="android5.light" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.android5.light.css" /> <link rel="dx-theme" data-theme="ios7.default" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.ios7.default.css" /> <link rel="dx-theme" data-theme="win10.black" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.win10.black.css" /> <link rel="dx-theme" data-theme="win10.white" href="https://cdn3.devexpress.com/jslib/17.1.3/css/dx.win10.white.css" /> <script src="https://cdn3.devexpress.com/jslib/17.1.3/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 data-bind="dxSelectBox: selectCompanyOptions"></div> <div id="form" data-bind="dxForm: formOptions"></div> </div> <div class="options"> <div class="caption">Options</div> <div class="option"> <span>Label location:</span> <div data-bind="dxSelectBox: labelLocationOptions"></div> </div> <div class="option"> <span>Columns count:</span> <div data-bind="dxSelectBox: colCountOptions"></div> </div> <div class="option"> <span>Min column width:</span> <div data-bind="dxSelectBox: minColWidthOptions"></div> </div> <div class="option"> <span>Form width:</span> <div data-bind="dxNumberBox: widthOptions"></div> </div> <div class="option"> <div data-bind="dxCheckBox: readOnlyOptions"></div> </div> <div class="option"> <div data-bind="dxCheckBox: showColonOptions"></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: #f5f5f5; } .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" }];