In Columns

Fixed and Floating Number of Columns

The Form widget can have a fixed number of columns in the layout...

JavaScript
$(function() {
    $("#formContainer").dxForm({
        formData: {
            firstName: "John",
            lastName: "Heart",
            position: "CEO"
        },
        colCount: 3
    });
});

... or it can vary the number of columns depending on the width of the container. To enable the latter mode, assign "auto" to the colCount option and specify the minimum column width using the minColWidth option. In this case, the maximum number of columns the layout can fit equals to floor(container_width / minColWidth). Note that groups and tabs can also have their own multi-column layouts inside.

JavaScript
$(function() {
    $("#formContainer").dxForm({
        formData: {
            firstName: "John",
            lastName: "Heart",
            hireDate: new Date(2012, 04, 13),
            city: "Los Angeles",
            phone: "+1(213) 555-9392",
            email: "jheart@dx-email.com"
        },
        colCount: "auto",
        minColWidth: 500,
        items: ["firstName", "lastName", {
            itemType: "tabbed",
            tabs: [{
                title: "Info",
                colCount: 3,
                items: ["position", "hireDate", "city" ]
            }, {
                title: "Contacts",
                colCount: 2,
                items: ["phone", "email"]
            }]
        }]
    });
});

Span Columns

If an item should span more than one column, assign the required number to the colSpan option. Groups and tabs can also have individual colSpan values.

JavaScript
$(function() {
    $("#formContainer").dxForm({
        formData: {
            firstName: "John",
            lastName: "Heart",
            notes: "John has been in the Audio/Video industry since 1990.",
            phone: "+1(213) 555-9392",
            email: "jheart@dx-email.com"
        },
        colCount: 2,
        items: ["firstName", "lastName", {
            dataField: "notes",
            colSpan: 2
        }, {
            itemType: "tabbed",
            colSpan: 2,
            tabs: [{
                title: "Contacts",
                items: ["phone", "email"]
            }]
        }]
    });
});

Layout Depending on the Screen Width

The Form widget enables you to specify different layouts for different screen widths. For this purpose, use the screenByWidth function and colCountByScreen option. The screenByWidth function returns a size qualifier depending on the screen width. The colCountByScreen option establishes the dependency between the size qualifier and the column count.

JavaScript
$(function() {
    $("#formContainer").dxForm({
        formData: {
            firstName: "John",
            lastName: "Heart",
            position: "CEO"
        },
        screenByWidth: function (width) {
            if (width < 768)  return "xs";
            if (width < 992)  return "sm";
            if (width < 1200) return "md";
            return "lg";
        },
        colCountByWidth: {
            "xs": 1, "md": 3,
            "sm": 2, "lg": 4
        }
    });
});
See Also