Create a Group
In the context of the Form widget, a group is called "group item". A group item can contain simple items, other groups, tabs or empty items. To create a group item, assign "group" to the itemType option. Items nested in the group are configured in the items array. To add a caption to the group, specify the caption option.
- $(function() {
- $("#formContainer").dxForm({
- formData: {
- firstName: "John",
- lastName: "Heart",
- position: "CEO",
- phone: "+1(213) 555-9392",
- email: "jheart@dx-email.com"
- },
- items: [{
- itemType: "group",
- caption: "Personal Data",
- items: ["firstName", "lastName", "position"]
- }, {
- itemType: "group",
- caption: "Contacts",
- items: ["phone", "email"]
- }]
- });
- });
Columns within a Group
Items within a group can be organized in several columns. To specify the number of columns, use the colCount option. Note that the entire Form layout can also be organized in columns if the colCount option is declared on the root level. In this case, use the colSpan option to define how many general columns the group must span.
- $(function() {
- $("#formContainer").dxForm({
- formData: {
- firstName: "John",
- lastName: "Heart",
- position: "CEO",
- phone: "+1(213) 555-9392",
- email: "jheart@dx-email.com"
- },
- // Splits the Form layout in two columns
- colCount: 2,
- items: [{
- itemType: "group",
- caption: "Personal Data",
- // Makes this group span both general columns
- colSpan: 2,
- // Organizes items inside this group in three columns
- colCount: 3,
- items: ["firstName", "lastName", "position"]
- }, {
- itemType: "group",
- caption: "Contacts",
- items: ["phone", "email"]
- }]
- });
- });
Custom Content within a Group
The Form widget allows you to place custom content, for example, an image, under the group caption.
- $("#formContainer").dxForm({
- formData: {
- firstName: "John",
- lastName: "Heart",
- picture: "http://here/goes/the/picture.jpg"
- },
- colCount: 2,
- items: [{
- itemType: "group",
- caption: "Picture",
- template: function (data, itemElement) {
- $("<img>").attr("src", data.formData.picture)
- .appendTo(itemElement)
- }
- }, {
- itemType: "group",
- caption: "Personal Data",
- items: ["firstName", "lastName"]
- }]
- });
See Also
If you have technical questions, please create a support ticket in the DevExpress Support Center.