JavaScript/jQuery Form - In Groups

Create a Group

In the context of the Form UI component, 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 property. Items nested in the group are configured in the items array. To add a caption to the group, specify the caption property.

JavaScript
  • $(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"]
  • }]
  • });
  • });

View Demo

Columns within a Group

Items within a group can be organized in several columns. To specify the number of columns, use the colCount property. Note that the entire Form layout can also be organized in columns if the colCount property is declared on the root level. In this case, use the colSpan property to define how many general columns the group must span.

JavaScript
  • $(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 UI component allows you to place custom content, for example, an image, under the group caption.

JavaScript
  • $("#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