DevExtreme jQuery/JS - In Tabs

Create a Tab

The Form widget allows you to organize items in tabs. In the context of the Form, tabs are called "tabbed items". A tabbed item can contain simple items, other tabs, groups or empty items. To create a tabbed item, assign "tabbed" to the itemType option. To specify the collection of tabs, use the tabs array. To define items displayed within an individual tab, use its items array.

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

View Demo

Columns within a Tab

The content of a tab can be organized in columns. The colCount option instructs the tab about how many columns it must have. 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 tab must span.

JavaScript
  • $(function() {
  • $("#formContainer").dxForm({
  • formData: {
  • name: "John Heart",
  • hireDate: new Date(2012, 4, 13),
  • city: "Los Angeles",
  • phone: "+1(213) 555-9392",
  • email: "jheart@dx-email.com"
  • },
  • // Splits the Form layout in two columns
  • colCount: 2,
  • items: ["name", {
  • itemType: "tabbed",
  • colSpan: 2,
  • tabs: [{
  • title: "Info",
  • // Makes this tab span both general columns
  • colSpan: 2,
  • // Organizes items inside this tab in three columns
  • colCount: 3,
  • items: ["position", "hireDate", "city"]
  • }, {
  • title: "Contacts",
  • colCount: 2,
  • items: ["phone", "email"]
  • }]
  • }]
  • });
  • });

Custom Content within a Tab

The Form widget allows you to specify custom templates for an individual tab and its content. For this purpose, assign callback functions to the tabTemplate and template options, respectively. With Angular, you can declare templates using the dxTemplate component.

JavaScript
  • $(function() {
  • $("#formContainer").dxForm({
  • formData: {
  • name: "John Heart",
  • birthDate: new Date(1964, 3, 15),
  • position: "CEO",
  • city: "Los Angeles",
  • phone: "+1(213) 555-9392",
  • email: "jheart@dx-email.com"
  • },
  • items: ["name", {
  • itemType: "tabbed",
  • tabs: [{
  • title: "Data Protection Policy",
  • tabTemplate: function (itemData, itemIndex, itemElement) {
  • itemElement.append("<p style='color: red'>" + itemData.title);
  • },
  • template: function (itemData, itemIndex, itemElement) {
  • itemElement.append("<p><i>By filling out this form,"
  • + " you agree to the terms of the"
  • + "<a href='#'>Data Protection Policy</a></i></p>");
  • }
  • }, {
  • title: "Info",
  • items: ["position", "birthDate", "city"]
  • }, {
  • title: "Contacts",
  • items: [ "phone", "email"]
  • }]
  • }]
  • });
  • });
See Also

Configure the Tab Panel

For displaying tabs, the Form uses the TabPanel widget. Therefore, you can specify any options of the TabPanel in the tabPanelOptions object.

JavaScript
  • $(function() {
  • $("#formContainer").dxForm({
  • formData: {
  • firstName: "John",
  • lastName: "Heart",
  • // ...
  • },
  • items: ["firstName", "lastName", {
  • itemType: "tabbed",
  • tabPanelOptions: {
  • height: 250,
  • onTitleClick: function (e) {
  • // ...
  • }
  • },
  • tabs: [ ... ]
  • }]
  • });
  • });
See Also