Vue CardView - Getting Started

DevExtreme includes multiple data management components. You can use them to display tabular, hierarchical, multidimensional data, or present information as cards. For more information about these components and their features, see How to Choose a Data Management Component.

NOTE
Before you start the tutorial, ensure DevExtreme is installed in your application.

CardView is a UI component that displays data in a card-based format. You can use it for employee directories, contact lists, product catalogs, and task boards.

This tutorial explains how to add a CardView to a page and configure the component's core settings.

Embedded applications are not available for the selected DevExtreme version (v25.1).
We recommend that you upgrade to the most recent version of DevExtreme to access the latest features, bug fixes, and security updates.

Each section in this tutorial covers a single configuration step. You can find the complete source code in the following GitHub repository:

View on GitHub

Create a CardView

Add DevExtreme to your Vue application and use the following code to create a CardView:

App.vue
  • <template>
  • <DxCardView id="card-view">
  • <!-- Configuration goes here -->
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • import 'devextreme/dist/css/dx.fluent.blue.light.css';
  • import DxCardView from 'devextreme-vue/card-view';
  • </script>

Bind CardView to Data

The CardView component can load and update data from different data source types. To use a local array, assign it to the dataSource property and specify the key field in the keyExpr property:

App.vue
data.ts
  • <template>
  • <DxCardView
  • :data-source="employees"
  • key-expr="ID">
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • // ...
  • import { employees } from './data.ts';
  • </script>
  • const employees = [
  • {
  • ID: 1,
  • FullName: "John Heart",
  • Position: "CEO",
  • Picture: "images/employees/01.png",
  • Department: "Management",
  • Phone: "+1 (213) 555-9392",
  • Email: "jheart@dx-email.com"
  • },
  • {
  • ID: 2,
  • FullName: "Samantha Bright",
  • Position: "COO",
  • Picture: "images/employees/30.png",
  • Department: "Management",
  • Phone: "+1 (213) 555-2858",
  • Email: "samanthab@dx-email.com"
  • },
  • {
  • ID: 3,
  • FullName: "Arthur Miller",
  • Position: "CTO",
  • Picture: "images/employees/10.png",
  • Department: "Management",
  • Phone: "+1 (310) 555-8583",
  • Email: "arthurm@dx-email.com"
  • },
  • {
  • ID: 4,
  • FullName: "Robert Reagan",
  • Position: "CMO",
  • Picture: "images/employees/03.png",
  • Department: "Management",
  • Phone: "+1 (818) 555-2387",
  • Email: "robertr@dx-email.com"
  • },
  • {
  • ID: 5,
  • FullName: "Greta Sims",
  • Position: "HR Manager",
  • Picture: "images/employees/04.png",
  • Department: "Human Resources",
  • Phone: "+1 (818) 555-6546",
  • Email: "gretas@dx-email.com"
  • },
  • {
  • ID: 6,
  • FullName: "Brett Wade",
  • Position: "IT Manager",
  • Picture: "images/employees/05.png",
  • Department: "IT",
  • Phone: "+1 (626) 555-0358",
  • Email: "brettw@dx-email.com"
  • },
  • ];

Configure Columns (Fields)

CardView uses the concept of columns from DataGrid. While it has rows and columns, the columns appear as fields on each card. The header shows the column names, and each field on a card includes a caption that usually matches the column dataField, and a unique value specific to the card.

The following code snippet restricts the CardView columns (fields) to FullName, Position, and Email and allows column reordering:

App.vue
  • <template>
  • <DxCardView ...
  • :allow-column-reordering="true"
  • >
  • <DxColumn data-field="FullName" :allow-hiding="false" />
  • <DxColumn data-field="Position" />
  • <DxColumn data-field="Email" />
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • // ...
  • import DxCardView, { DxColumn } from 'devextreme-vue/card-view';
  • </script>

Filter and Search Data

The CardView includes the following UI elements used to search and filter data:

In this tutorial, the header filter and the search panel are displayed:

App.vue
  • <template>
  • <DxCardView ... >
  • <DxHeaderFilter :visible="true" />
  • <DxSearchPanel :visible="true" />
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • // ...
  • import DxCardView, { DxHeaderFilter, DxSearchPanel } from 'devextreme-vue/card-view';
  • </script>

Select Cards

CardView supports single and multiple selection modes. Use the selection.mode property to specify the mode.

App.vue
  • <template>
  • <DxCardView ... >
  • <DxSelection mode="multiple" />
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • // ...
  • import DxCardView, { DxSelection } from 'devextreme-vue/card-view';
  • </script>

Add Pagination

To add pagination to CardView, configure the following settings:

  • paging - enables paging
  • pager - activates UI elements for pagination
App.vue
  • <template>
  • <DxCardView ... >
  • <DxPaging :page-size="3" />
  • <DxPager
  • :show-info="true"
  • :show-navigation-buttons="true"
  • :show-page-size-selector="true"
  • />
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • // ...
  • import DxCardView, { DxPaging, DxPager } from 'devextreme-vue/card-view';
  • </script>

Configure Column Chooser

CardView displays all columns from the columns array. To hide a column, set its visible property to false. Hidden columns appear in the columnChooser. Users can restore hidden columns from it. To enable the column chooser, set the columnChooser.enabled property to true. If a column should not be visible in the column chooser, do not declare it in the columns array.

You can also specify other column chooser settings, such as mode, position, and selection:

App.vue
  • <template>
  • <DxCardView ... >
  • <DxColumnChooser
  • :enabled="true"
  • :height="340"
  • mode="select"
  • >
  • <DxPosition
  • my="right top"
  • at="right bottom"
  • of=".dx-cardview-column-chooser-button"
  • />
  • <DxSelection :select-by-click="true" />
  • </DxColumnChooser>
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • // ...
  • import DxCardView, { DxColumnChooser, DxPosition, DxSelection } from 'devextreme-vue/card-view';
  • </script>