Angular CardView Properties
A configuration object for the CardView UI component.
See Also
accessKey
Specifies the shortcut key that sets focus on the UI component.
The value of this property will be passed to the accesskey
attribute of the HTML element that underlies the UI component.
activeStateEnabled
Specifies whether the UI component changes its visual state as a result of user interaction.
The UI component switches to the active state when users press down the primary mouse button. When this property is set to true, the CSS rules for the active state apply. You can change these rules to customize the component.
Use this property when you display the component on a platform whose guidelines include the active state change for UI components.
allowColumnReordering
Specifies whether a user can reorder columns.
This property reorders header panel items.
cardContentTemplate
Specifies a custom template for card content.
jQuery
$('#card-view').dxCardView({ // ... cardContentTemplate: (info) => { return createVehicleCardContent(info.card); }, }) const createVehicleCardContent = (card) => { const { TrademarkName, Name, CategoryName } = card.data; const name = `${TrademarkName} ${Name}`; const priceText = card.fields.find(f => f.column.dataField === 'Price')?.text; return $('<div>').append( $('<div>').text(name).attr('title', name), $('<div>').text(priceText), $('<div>').text(CategoryName) ) };
Angular
<dx-card-view ... cardContentTemplate="vehicleCardContentTemplate" > <div *dxTemplate="let model of 'vehicleCardContentTemplate'"> <ng-container *ngIf="model.card?.data as data"> <div> <div title="{{ data.trademarkName + ' ' + data.Name }}"> {{ data.TrademarkName + ' ' + data.Name }} </div> <div>{{ getFormattedPrice(model.card) }}</div> <div>{{ data.CategoryName }}</div> </div> </ng-container> </div> </dx-card-view>
import { CardInfo } from 'devextreme-angular/ui/card-view'; // ... export class AppComponent { getFormattedPrice(card: CardInfo): string { const priceText = card.fields.find(f => f?.column?.dataField === 'Price'); return priceText?.text ?? ''; } }
Vue
<template> <DxCardView ... card-content-template="vehicleCardContentTemplate" > <template #vehicleCardContentTemplate="{ data: { card } }"> <div> <div :title="`${card.data.TrademarkName} ${card.data.Name}`"> {{ card.data.TrademarkName + ' ' + card.data.Name }} </div> <div>{{ card.fields?.find(f => f.column?.dataField === 'Price')?.text }}</div> <div>{{ card.data.CategoryName }}</div> </div> </template> </DxCardView> </template>
React
import CardView, { CardViewTypes } from "devextreme-react/card-view" // ... function vehicleCardContentRender(model: CardViewTypes.CardTemplateData) { const { TrademarkName, Name, CategoryName } = model.card.data; const name = `${TrademarkName} ${Name}`; const price = model.card.fields.find(f => f.column.dataField === 'Price')?.text; return ( <div> <div title={name}>{name}</div> <div>{price}</div> <div>{CategoryName}</div> </div> ) } function App() { return ( <CardView ... cardContentRender={vehicleCardContentRender} > </CardView> ) }
cardCover
Configures the card cover.
jQuery
$(#dxCardView).dxCardView({ // ... cardCover: { imageExpr: (data) => data.imgUrl, altExpr: (data) => data.imgAlt, aspectRatio: 3.5, maxHeight: 200, } })
Angular
<dx-card-view ... > <dxo-card-view-card-cover imageExpr="imgUrlExpr" altExpr="imgAltExpr" aspectRatio="3.5" maxHeight="200" ></dxo-card-view-card-cover> </dx-card-view>
// ... export class AppComponent { imgUrlExpr(data: Employee): string { return data.imgUrl; } imgAltExpr(data: Employee): string { return data.imgAlt; } }
Vue
<template> <DxCardView ... > <DxCardCover image-expr="imgUrlExpr" alt-expr="imgAltExpr" aspect-ratio="3.5" max-height="200" /> </DxCardView> </template> <script setup lang="ts"> import DxCardView, { DxCardCover } from 'devextreme-vue/card-view'; function imgUrlExpr(data: Employee): string { return data.imgUrl; } function imgAltExpr(data: Employee): string { return data.imgAlt; } </script>
React
import CardView, { CardCover } from 'devextreme-react/card-view'; function imgUrlExpr(data: Employee): string { return data.imgUrl; } function imgAltExpr(data: Employee): string { return data.imgAlt; } function App() { return ( <CardView ... > <CardCover imageExpr="imgUrlExpr" altExpr="imgAltExpr" aspectRatio="3.5" maxHeight="200" /> </CardView> ) }
cardFooterTemplate
Specifies a custom template for a card footer.
jQuery
$(#dxCardView).dxCardView({ // ... cardFooterTemplate() { return $('<div>').dxButton({ text: 'Click', onClick() { // Implement custom logic here } }) }, })
Angular
<dx-card-view ... cardFooterTemplate="footerTemplate" > <div *dxTemplate="let params of 'footerTemplate'"> <dx-button text="Click" (onClick)="handleOnClick()" // Implement custom logic here ></dx-button> </div> </dx-card-view>
Vue
<template> <DxCardView ... card-footer-template="footerTemplate" > <template #footerTemplate="{ data }"> <DxButton text="Click" @click="handleOnClick" // Implement custom logic here /> </template> </DxCardView> </template> <script setup lang="ts"> import DxCardView from 'devextreme-vue/card-view'; import DxButton from 'devextreme-vue/button'; </script>
React
import CardView from 'devextreme-react/card-view'; import Button from 'devextreme-react/button'; function CardFooterTemplate() { return ( <Button text="Click" onClick={handleOnClick} // Implement custom logic here /> ) } function App() { return ( <CardView ... cardContentRender={CardFooterTemplate} /> ) }
cardHeader
Configures the card header.
jQuery
$(#dxCardView).dxCardView({ // ... cardHeader: { visible: true, template: (data, container) => { const text = data.card.data.Task_Subject; $(container).addClass('task__header-container'); return $('<div>') .addClass('task__header') .attr('title', text) .text(text); }, }, })
Angular
<dx-card-view> <dxo-card-view-card-header [visible]="true" template="headerTemplate" > </dxo-card-view-card-header> <div *dxTemplate="let model of 'headerTemplate'"> <card-header [text]="model.card.data.Task_Subject" /> </div> </dx-card-view>
<div class="header" [title]="text"> {{ text }} </div>
Vue
<template> <DxCardView> <DxCardHeader :visible="true" template="headerTemplate" /> <template #headerTemplate="{ data: { card: { data: task, } } }"> <HeaderTemplate :text="task.Task_Subject"/> </template> </DxCardView> </template> <script setup lang="ts"> import DxCardView, { DxCardHeader } from 'devextreme-vue/card-view'; </script>
<template> <div className="task__header" :title="text"> {{ text }} </div> </template> <script setup lang="ts"> defineProps<{ text: string, }>(); </script>
React
import CardView, { CardHeader ) from 'devextreme-react/card-view'; function App() { return ( <CardView> <CardHeader visible={true} render={ (model) => <HeaderTemplate text={((model.card.data) as Task).Task_Subject} /> } /> </CardView> ) } <!-- HeaderTemplate.tsx --> import React from 'react'; interface HeaderTemplateProps { text: string; } const HeaderTemplate = ({ text }: HeaderTemplateProps) => { return ( <div className="task__header" title={text}> {text} </div> ); } export default HeaderTemplate;
cardTemplate
Specifies a custom template for the card.
jQuery
$('#card-view').dxCardView({ // ... cardTemplate: (info) => { return createVehicleCard(info.card); }, }) const createVehicleCard = (card) => { const { TrademarkName, Name, CategoryName, ID } = card.data; const cardEl = $('<div>'); const name = `${TrademarkName} ${Name}`; const priceText = card.fields.find(f => f.column.dataField === 'Price')?.text; const vehicleInfo = $('<div>').append( $('<div>').text(name).attr('title', name), $('<div>').text(priceText), $('<div>').text(CategoryName) ) const imageWrapper = $('<div>').append( $('<img>').attr({ src: `images/vehicles/image_${ID}.png`, alt: name, }) ); cardEl.append(imageWrapper, vehicleInfo); return cardEl; };
Angular
<dx-card-view ... cardTemplate="vehicleCardTemplate" > <div *dxTemplate="let model of 'vehicleCardTemplate'"> <ng-container *ngIf="model.card?.data as data"> <div> <img src="images/vehicles/image_{{ data.ID }}.png" alt="{{ data.trademarkName + ' ' + data.Name }}" /> </div> <div> <div title="{{ data.trademarkName + ' ' + data.Name }}"> {{ data.TrademarkName + ' ' + data.Name }} </div> <div>{{ getFormattedPrice(model.card) }}</div> <div>{{ data.CategoryName }}</div> </div> </ng-container> </div> </dx-card-view>
import { CardInfo } from 'devextreme-angular/ui/card-view'; // ... export class AppComponent { getFormattedPrice(card: CardInfo): string { const priceText = card.fields.find(f => f?.column?.dataField === 'Price'); return priceText?.text ?? ''; } }
Vue
<template> <DxCardView ... card-template="vehicleCardTemplate" > <template #vehicleCardTemplate="{ data: { card } }"> <div> <div> <img :src="`images/vehicles/image_${card.data.ID}.png`" :alt="`${card.data.TrademarkName} ${card.data.Name}`" > </div> <div> <div :title="`${card.data.TrademarkName} ${card.data.Name}`"> {{ card.data.TrademarkName + ' ' + card.data.Name }} </div> <div>{{ card.fields?.find(f => f.column?.dataField === 'Price')?.text }}</div> <div>{{ card.data.CategoryName }}</div> </div> </div> </template> </DxCardView> </template>
React
import CardView, { CardViewTypes } from "devextreme-react/card-view" // ... function vehicleCardRender(model: CardViewTypes.CardTemplateData) { const { TrademarkName, Name, CategoryName, ID } = model.card.data; const name = `${TrademarkName} ${Name}`; const price = model.card.fields.find(f => f.column.dataField === 'Price')?.text; return ( <div> <div> <img src={`images/vehicles/image_${ID}.png`} alt={name} /> </div> <div> <div title={name}>{name}</div> <div>{price}</div> <div>{CategoryName}</div> </div> </div> ) } function App() { return ( <CardView ... cardRender={vehicleCardRender} > </CardView> ) }
columns[]
An array of CardView columns.
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.
dataSource
Binds the UI component to data.
CardView works with collections of objects.
Depending on your data source, bind CardView to data as follows.
Data Array
Assign the array to the dataSource option and specify the keyExpr.Read-Only Data in JSON Format
Set the dataSource property to the URL of a JSON file or service that returns JSON data.OData
Implement an ODataStore. Make sure to specify the key.Web API, PHP, MongoDB
Use one of the following extensions to enable the server to process data according to the protocol DevExtreme UI components use:Then, use the createStore method to configure access to the server on the client as shown below. This method is part of DevExtreme.AspNet.Data.
jQuery
JavaScript$(function() { let serviceUrl = "https://url/to/my/service"; $("#cardViewContainer").dxCardView({ // ... dataSource: DevExpress.data.AspNet.createStore({ key: "ID", loadUrl: serviceUrl + "/GetAction", insertUrl: serviceUrl + "/InsertAction", updateUrl: serviceUrl + "/UpdateAction", deleteUrl: serviceUrl + "/DeleteAction" }) }) });
Angular
app.component.tsapp.component.htmlapp.module.tsimport { Component } from '@angular/core'; import CustomStore from 'devextreme/data/custom_store'; import { createStore } from 'devextreme-aspnet-data-nojquery'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { store: CustomStore; constructor() { let serviceUrl = "https://url/to/my/service"; this.store = createStore({ key: "ID", loadUrl: serviceUrl + "/GetAction", insertUrl: serviceUrl + "/InsertAction", updateUrl: serviceUrl + "/UpdateAction", deleteUrl: serviceUrl + "/DeleteAction" }) } }
<dx-card-view ... [dataSource]="store"> </dx-card-view>
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { DxCardViewModule } from 'devextreme-angular'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxCardViewModule ], providers: [], bootstrap: [AppComponent] }) export class AppModule { }
Vue
App.vue<template> <DxCardView ... :data-source="store" /> </template> <script> import 'devextreme/dist/css/dx.light.css'; import CustomStore from 'devextreme/data/custom_store'; import { createStore } from 'devextreme-aspnet-data-nojquery'; import { DxCardView } from 'devextreme-vue/card-view'; export default { components: { DxCardView }, data() { const serviceUrl = "https://url/to/my/service"; const store = createStore({ key: "ID", loadUrl: serviceUrl + "/GetAction", insertUrl: serviceUrl + "/InsertAction", updateUrl: serviceUrl + "/UpdateAction", deleteUrl: serviceUrl + "/DeleteAction" }); return { store } } } </script>
React
App.jsimport React from 'react'; import 'devextreme/dist/css/dx.light.css'; import CustomStore from 'devextreme/data/custom_store'; import { createStore } from 'devextreme-aspnet-data-nojquery'; import CardView from 'devextreme-react/card-view'; const serviceUrl = "https://url/to/my/service"; const store = createStore({ key: "ID", loadUrl: serviceUrl + "/GetAction", insertUrl: serviceUrl + "/InsertAction", updateUrl: serviceUrl + "/UpdateAction", deleteUrl: serviceUrl + "/DeleteAction" }); class App extends React.Component { render() { return ( <CardView ... dataSource={store} /> ); } } export default App;
Any other data source
Implement a CustomStore.
Regardless of the data source on the input, the CardView always wraps it in the DataSource object. This object allows you to sort, filter, group, and perform other data shaping operations. To get its instance, call the getDataSource() method.
Review the following notes about data binding:
Field names cannot be equal to
this
and should not contain the following characters:.
,:
,[
, and]
.CardView does not execute dataSource.sort functions. To implement custom sorting logic, implement columns[].calculateSortValue.
If the CardView UI component gets data from a server, configure remoteOperations to notify the UI component about data operations the server performs.
jQuery
- The stores are immutable. You cannot change their configurations at runtime. Instead, create a new store or DataSource and assign it to the dataSource property as shown in the following help topic: Get and Set Properties.
Angular
- The stores are immutable. You cannot change their configurations at runtime. Instead, create a new store or DataSource and assign it to the dataSource property as shown in the following help topic: Two-Way Property Binding.
Vue
- The stores are immutable. You cannot change their configurations at runtime. Instead, create a new store or DataSource and assign it to the dataSource property as shown in the following help topic: Two-Way Property Binding.
React
- The stores are immutable. You cannot change their configurations at runtime. Instead, create a new store or DataSource and assign it to the dataSource property as shown in the following help topic: Controlled Mode.
disabled
Specifies whether the UI component responds to user interaction.
editing
Configures editing.
The UI component can allow a user to add, update and delete data. To control which of these operations are allowed, use the allowAdding, allowUpdating and allowDeleting properties.
elementAttr
Specifies the global attributes to be attached to the UI component's container element.
jQuery
$(function(){ $("#cardViewContainer").dxCardView({ // ... elementAttr: { id: "elementId", class: "class-name" } }); });
Angular
<dx-card-view ... [elementAttr]="{ id: 'elementId', class: 'class-name' }"> </dx-card-view>
import { DxCardViewModule } from "devextreme-angular"; // ... export class AppComponent { // ... } @NgModule({ imports: [ // ... DxCardViewModule ], // ... })
Vue
<template> <DxCardView ... :element-attr="cardViewAttributes"> </DxCardView> </template> <script> import DxCardView from 'devextreme-vue/card-view'; export default { components: { DxCardView }, data() { return { cardViewAttributes: { id: 'elementId', class: 'class-name' } } } } </script>
React
import React from 'react'; import CardView from 'devextreme-react/card-view'; class App extends React.Component { cardViewAttributes = { id: 'elementId', class: 'class-name' } render() { return ( <CardView ... elementAttr={this.cardViewAttributes}> </CardView> ); } } export default App;
errorRowEnabled
Indicates whether to show the error row.
The error row displays data-related errors that may occur on the server during the UI component's runtime. Setting this property to false
hides the error row, but the errors can still be viewed in the browser's console.
See Also
filterBuilderPopup
Configures the integrated filter builder popup.
See the Popup configuration for properties that you can specify in this object.
Angular
Vue
focusStateEnabled
Specifies whether the UI component can be focused using keyboard navigation.
height
Specifies the UI component's height.
This property accepts a value of one of the following types:
Number
The height in pixels.String
A CSS-accepted measurement of height. For example,"55px"
,"20vh"
,"80%"
,"inherit"
.
hint
Specifies text for a hint that appears when a user pauses on the UI component.
hoverStateEnabled
Specifies whether the UI component changes its appearance when a user hovers over it.
keyExpr
Specifies the key property (or properties) that supply key values to access data items. Each key value must be unique. This property applies only if data is a simple array.
See Also
- key in ArrayStore | CustomStore | LocalStore | ODataStore
loadPanel
Configures the load panel.
The load panel is displayed while the UI component loads data. It consists of a loading indicator and text, both placed on a pane.
Since the load panel is, in fact, the DevExtreme LoadPanel UI component, the loadPanel object can contain any properties of this UI component.
See Also
noDataText
Specifies a text string to display when no data appears in CardView.
onCardClick
A function that is executed when a card is clicked or tapped.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
card |
The card properties. |
|
cardElement |
The card's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
onCardDblClick
A function that is executed when a card is double-clicked or double-tapped.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
card |
The card properties. |
|
cardElement |
The card's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
onCardHoverChanged
A function that is executed after the pointer enters or leaves a card.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
card |
The card properties. |
|
cardElement |
The card's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
eventType |
Indicates whether the pointer entered or left the card. Can be either "mouseover" or "mouseout". |
onCardInserted
A function that is executed after a new card is inserted into the data source.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
data |
The data of the card. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onCardInserting
A function that is executed before a new card is inserted into the data source.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
cancel |
|
|
component | CardView |
The UI component's instance. |
data |
The data of the card that should be inserted. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onCardPrepared
A function that is executed after a card is created.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
card |
The card properties. |
|
cardElement |
The card's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onCardRemoved
A function that is executed after a card was removed from the data source.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
data | any |
The card data. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
key | any |
The card's key. |
onCardRemoving
A function that is executed before a card is removed from the data source.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
cancel |
|
|
component | CardView |
The UI component's instance. |
data | any |
The data of the card that should be removed. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
key | any |
The card's key. |
onCardSaved
A function that is executed after card changes are saved.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
changes | Array<DataChange> |
All card data (including changes). Differs from onCardSaving, which only consists of pending changes. |
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onCardSaving
A function that is executed before pending card changes are saved.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
cancel |
Set this field to |
|
changes | Array<DataChange> |
Pending row changes; a copy of the editing.changes array. Includes only card changes, unlike onCardSaved, which contains all card data (including changes). |
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
promise |
Assign a Promise to this field to perform an asynchronous operation, such as a request to a server. |
onCardUpdated
A function that is executed after a card is updated in the data source.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
data | any |
The updated data of the card. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
key | any |
The card's key. |
onCardUpdating
A function that is executed before a card is updated in the data source.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
cancel |
|
|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
key | any |
The card's key. |
newData |
The card's updated data. |
|
oldData | any |
The card's old data. |
onContentReady
A function that is executed when the UI component is rendered and each time the component is repainted.
Information about the event.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onContextMenuPreparing
A function that is executed before the context menu is rendered.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
card | any |
The card properties. |
cardIndex |
The index of the card on which the context menu is invoked. |
|
column |
This column's configuration. |
|
columnIndex |
The index of the column on which the context menu is invoked. |
|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
items | Array<any> |
Items to be displayed in the context menu. Their structure is described in the items property description. Each item also contains the onItemClick event handler, which allows you to access the clicked or tapped item's data. |
target |
The name of the element on which the context menu is invoked: "headerPanel", "content", or "toolbar". This field is read-only. |
|
targetElement |
The target element's container. It is an HTML Element or a jQuery Element when you use jQuery. |
In the following code, the onContextMenuPreparing function adds a custom item to the context menu that is invoked when a user right-clicks any column header:
jQuery
$(function() { $("#cardViewContainer").dxCardView({ // ... onContextMenuPreparing: function(e) { if (e.target == "headerPanel") { // e.items can be undefined if (!e.items) e.items = []; // Add a custom menu item e.items.push({ text: "Log Column Caption", onItemClick: function() { console.log(e.column.caption); } }); } } }); });
Angular
<dx-card-view ... (onContextMenuPreparing)="addMenuItems($event)"> </dx-card-view>
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { addMenuItems(e) { if (e.target == 'headerPanel') { // e.items can be undefined if (!e.items) e.items = []; // Add a custom menu item e.items.push({ text: 'Log Column Caption', onItemClick: () => { console.log(e.column.caption); } }); } } }
Vue
<template> <DxCardView ... @context-menu-preparing="addMenuItems"> </DxCardView> </template> <script setup> import 'devextreme/dist/css/dx.light.css'; import DxCardView from 'devextreme-vue/card-view'; const addMenuItems = (e) => { if (e.target == 'headerPanel') { // e.items can be undefined if (!e.items) e.items = []; // Add a custom menu item e.items.push({ text: 'Log Column Caption', onItemClick: () => { console.log(e.column.caption); } }); } } </script>
React
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import CardView from 'devextreme-react/card-view'; const App = () => { const addMenuItems = (e) => { if (e.target == 'headerPanel') { // e.items can be undefined if (!e.items) e.items = []; // Add a custom menu item e.items.push({ text: 'Log Column Caption', onItemClick: () => { console.log(e.column.caption); } }); } } return ( <CardView ... onContextMenuPreparing={this.addMenuItems}> </CardView> ); } export default App;
onDataErrorOccurred
A function that is executed when an error occurs in the data source.
Information on the occurred error.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
error |
The standard Error object that defines the error. |
|
model | any |
Model data. Available only if you use Knockout. |
Handles errors that might occur in the data source. To obtain a human-readable description of the error in the function, use the error.message field.
onDisposing
A function that is executed before the UI component is disposed of.
Information about the event.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onEditCanceled
A function that is executed after card changes are discarded.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
changes | Array<DataChange> |
Discarded card changes. |
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onEditCanceling
A function that is executed when the edit operation is canceled, but card changes are not yet discarded.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
cancel |
Set this field to |
|
changes | Array<DataChange> |
Card changes to be discarded. |
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
An edit operation can be canceled from the UI (with the Cancel button) or programatically (with the cancelEditData() method).
onEditingStart
A function that is executed before a card switches to the editing state.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
cancel |
Allows you to cancel card editing. |
|
component | CardView |
The UI component's instance. |
data |
The data of a card to be edited. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
key | any |
The card's key. An added card not saved has the |
onFieldCaptionClick
A function that is executed when a field caption is clicked or tapped.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
field |
The field information. |
|
fieldCaptionElement |
The field caption's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onFieldCaptionDblClick
A function that is executed when a field caption is double-clicked or double-tapped.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
field |
The field information. |
|
fieldCaptionElement |
The field caption's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onFieldCaptionPrepared
A function that is executed after a field caption is created.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
field |
The field information. |
|
fieldCaptionElement |
The field caption's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onFieldValueClick
A function that is executed when a field value is clicked or tapped.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
field |
The field information. |
|
fieldValueElement |
The field value's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onFieldValueDblClick
A function that is executed when a field value is double-clicked or double-tapped.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
event | Event (jQuery or EventObject) |
The event that caused the function to execute. It is an EventObject or a jQuery.Event when you use jQuery. |
field |
The field information. |
|
fieldValueElement |
The field value's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onFieldValuePrepared
A function that is executed after a field value is created.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
field |
The field information. |
|
fieldValueElement |
The field value's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onFocusedCardChanged
A function that is executed after the focused card changes.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
card |
The card properties. |
|
cardElement |
The focused card's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
onInitialized
A function used in JavaScript frameworks to save the UI component instance.
Information about the event.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
See Also
jQuery
Angular
Vue
React
onInitNewCard
A function that is executed before a new card is added to the UI component.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
data |
The data of the inserted card; initially empty. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
promise |
Assign a Promise to this field to perform an asynchronous operation, such as a request to a server. |
onOptionChanged
A function that is executed after a UI component property is changed.
Information about the event.
Name | Type | Description |
---|---|---|
model | any |
Model data. Available only if you use Knockout. |
fullName |
The path to the modified property that includes all parent properties. |
|
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
component | CardView |
The UI component's instance. |
name |
The modified property if it belongs to the first level. Otherwise, the first-level property it is nested into. |
|
value | any |
The modified property's new value. |
previousValue | any |
The UI component's previous value. |
The following example shows how to subscribe to component property changes:
jQuery
$(function() { $("#cardViewContainer").dxCardView({ // ... onOptionChanged: function(e) { if(e.name === "changedProperty") { // handle the property change here } } }); });
Angular
<dx-card-view ... (onOptionChanged)="handlePropertyChange($event)"> </dx-card-view>
import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { // ... handlePropertyChange(e) { if(e.name === "changedProperty") { // handle the property change here } } }
import { BrowserModule } from '@angular/platform-browser'; import { NgModule } from '@angular/core'; import { AppComponent } from './app.component'; import { DxCardViewModule } from 'devextreme-angular'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, DxCardViewModule ], providers: [ ], bootstrap: [AppComponent] }) export class AppModule { }
Vue
<template> <DxCardView ... @option-changed="handlePropertyChange" /> </template> <script> import 'devextreme/dist/css/dx.light.css'; import DxCardView from 'devextreme-vue/card-view'; export default { components: { DxCardView }, // ... methods: { handlePropertyChange: function(e) { if(e.name === "changedProperty") { // handle the property change here } } } } </script>
React
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import CardView from 'devextreme-react/card-view'; const handlePropertyChange = (e) => { if(e.name === "changedProperty") { // handle the property change here } } export default function App() { return ( <CardView ... onOptionChanged={handlePropertyChange} /> ); }
onSelectionChanged
A function that is executed when a card is selected or its selection is cleared.
Information about the event that caused the function's execution.
Name | Type | Description |
---|---|---|
component | CardView |
The UI component's instance. |
currentDeselectedCardKeys | Array<any> |
The keys of the cards whose selection was cleared. |
currentSelectedCardKeys | Array<any> |
The keys of the cards that were selected. |
element |
The UI component's container. It is an HTML Element or a jQuery Element when you use jQuery. |
|
selectedCardKeys | Array<any> |
The keys of all selected cards. |
selectedCardsData | Array<any> |
The data of all selected cards. |
pager
Configures the pager.
The pager is an element that allows users to navigate through pages and change their size at runtime. The pager consists of the page navigator and several optional elements: the page size selector, navigation buttons, and page information.
jQuery
$(function() { $("#card-view").dxCardView({ // ... paging: { pageSize: 3, }, pager: { showInfo: true, showNavigationButtons: true, showPageSizeSelector: true }, }); });
Angular
<dx-card-view ... > <dxo-card-view-paging [pageSize]="3"></dxo-card-view-paging> <dxo-card-view-pager [showInfo]="true" [showNavigationButtons]="true" [showPageSizeSelector]="true" ></dxo-card-view-pager> </dx-card-view>
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>
React
import React from 'react'; import 'devextreme/dist/css/dx.light.css'; import CardView, { Paging, Pager } from 'devextreme-react/card-view'; function App() { return ( <CardView ... > <Paging pageSize={3} /> <Pager showInfo={true} showNavigationButtons={true} showPageSizeSelector={true} /> </CardView> ); } export default App;
paging
Configures paging.
Paging allows the UI component to load data in portions instead of loading it simultaneously. To enable paging, set the paging.enabled property to true
.
Users can switch between pages and change paging settings using the pager or they can scroll the pages. Paging settings apply with any scrolling mode.
remoteOperations
Notifies CardView of the server's data processing operations.
Server-side data processing improves the UI component's performance on large datasets. When the server does not implement particular operations (and/or the corresponding remoteOperations fields are false
) they are executed on the client. Note that the UI component may send queries to the server while executing a client-side operation.
false
. Other operations are always client-side.rtlEnabled
Switches the UI component to a right-to-left representation.
When this property is set to true, the UI component text flows from right to left, and the layout of elements is reversed. To switch the entire application/site to the right-to-left representation, assign true to the rtlEnabled field of the object passed to the DevExpress.config(config) method.
DevExpress.config({ rtlEnabled: true });
selectedCardKeys
Allows you to select cards or determine which cards are selected.
Array<any>
selection
Configures runtime selection.
A user can select rows in a single or multiple mode. In multiple mode, a user can select all rows at once. To disable this feature, assign false
to the allowSelectAll property.
See Also
tabIndex
Specifies the number of the element when the Tab key is used for navigating.
The value of this property will be passed to the tabindex
attribute of the HTML element that underlies the UI component.
width
Specifies the UI component's width.
This property accepts a value of one of the following types:
Number
The width in pixels.String
A CSS-accepted measurement of width. For example,"55px"
,"20vw"
,"80%"
,"auto"
,"inherit"
.
If you have technical questions, please create a support ticket in the DevExpress Support Center.