Your search did not match any results.
Form

Columns Adaptability

Documentation
The Form widget can use different layouts depending on the screen width. The dependency between column count and the screen width is specified using the colCountByScreen option, which has a higher priority than the colCount and the minColWidth options. In this demo, the form is displayed using a 4-column layout on wide screens and a 2-column layout on narrow screens. Switch between the landscape and portrait layouts to see how the form looks on wide and narrow screens.
Copy to Codepen
Apply
Reset
window.onload = function() { var colCountMiddleSize = ko.observable(4), colCountSmallSize = ko.observable(2); var viewModel = { formOptions: { formData: employees, labelLocation: "top", minColWidth: 233, colCount: "auto", colCountByScreen: { md: colCountMiddleSize, sm: colCountSmallSize }, screenByWidth: function(width) { return width < 720? "sm" : "md"; } }, useColCountByScreen: { onValueChanged: function(e) { if(e.value) { colCountMiddleSize(4); colCountSmallSize(2); } else { colCountMiddleSize(undefined); colCountSmallSize(undefined); } }, text: "Set the count of columns regardless of screen size", value: true } }; ko.applyBindings(viewModel, document.getElementById("form-container")); };
<!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/16.2.5/css/dx.spa.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/16.2.5/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/16.2.5/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/16.2.5/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-container"> <div id="form" data-bind="dxForm: formOptions"></div> <div class="option" data-bind="dxCheckBox: useColCountByScreen"></div> </div> </div> </body> </html>
#form { padding-left: 8px; } .option { margin: 30px 0 10px 8px; }
var employees = { "ID": 1, "FirstName": "John", "LastName": "Heart", "CompanyName": "Super Mart of the West", "Position": "CEO", "OfficeNo": "901", "BirthDate": new Date(1964, 2, 16), "HireDate": new Date(1995, 0, 15), "Address": "351 S Hill St.", "City": "Los Angeles", "State": "CA", "Zipcode": "90013", "Phone": "+1(213) 555-9392", "Email": "jheart@dx-email.com", "Skype": "jheart_DX_skype" };