Vue CardView - ColumnProperties

Configures column properties.

import { DxCardViewTypes } from "devextreme-vue/card-view"
Type: DxCardViewTypes.ColumnProperties

alignment

Aligns the content of the entire column.

Type:

HorizontalAlignment

| undefined

The default alignment for all types of content is 'left'.

allowEditing

Specifies whether a user can edit cards in this column at runtime. Inherits the value of the editing.allowUpdating property.

Type:

Boolean

Default Value: true

allowFiltering

Specifies whether data can be filtered by this column.

Type:

Boolean

Default Value: true

allowHeaderFiltering

Specifies whether data of this column can be filtered in header filter. Inherits the value of the allowFiltering property.

Type:

Boolean

Default Value: true

allowHiding

Specifies whether a user can hide the column using the column chooser at runtime. Applies only if columnChooser.enabled is true.

Type:

Boolean

Default Value: true

allowReordering

Specifies whether users can reorder this column. Overrides the allowColumnReordering property value.

Type:

Boolean

Default Value: true

allowSearch

Specifies whether this column can be searched. Applies only if searchPanel.visible is true. Inherits the value of the allowFiltering property.

Type:

Boolean

Default Value: true

allowSorting

Specifies whether a user can sort rows by this column at runtime. Applies only if sorting.mode differs from "none".

Type:

Boolean

Default Value: true

calculateDisplayValue

Calculates custom display values for column fields. Requires specifying the dataField or calculateFieldValue property.

Type:

Function

Function parameters:
cardData:

Object

The data of the card to which the field belongs.

Context:

Column

The this keyword refers to the column's configuration.

Return Value: any

The value for the field to display.

This property accepts the name of the data source field that supplies display values or a function that combines display values. Specify this function only if all data processing operations are executed on the client.

App.vue
  • <template>
  • <DxCardView>
  • <DxColumn
  • data-field="countryID" <!-- supplies values for editing -->
  • :calculate-display-value="getCountryWithCapital" <!-- combines display values -->
  • />
  • </DxCardView>
  • </template>
  •  
  • <script>
  • import 'devextreme/dist/css/dx.fluent.blue.light.css';
  •  
  • import DxCardView, {
  • DxColumn
  • } from 'devextreme-vue/card-view';
  •  
  • export default {
  • components: {
  • DxCardView,
  • DxColumn
  • },
  • methods: {
  • getCountryWithCapital(rowData) {
  • return rowData.capital + " (" + rowData.country + ")";
  • }
  • }
  • }
  • </script>

The UI component utilizes the specified display values in sorting and searching.

Do not use this property to format text in cells. Instead, use the format, customizeText, or fieldTemplate property.

calculateFieldValue

Calculates custom field values.

Type:

Function

Function parameters:
cardData:

Object

The data of the card to which the field belongs.

Context:

Column

The this keyword refers to the column's configuration.

Return Value: any

A field's custom value.

App.vue
  • <template>
  • <DxCardView ... >
  • <DxColumn
  • caption="Location"
  • :calculate-field-value="calculateLocation"
  • />
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • import DxCardView, { DxColumn } from 'devextreme-vue/card-view';
  •  
  • function calculateLocation(cardData: Employee): string {
  • return `${cardData.City}, ${cardData.State}`;
  • }
  • </script>

calculateFilterExpression

Specifies the column's custom rules to filter data.

Type:

Function

Function parameters:
filterValue: any

A user input value.
Contains an array if the selectedFilterOperation is one of the following: "between", "anyof", "noneof".

selectedFilterOperation:

String

| null

A selected filter operation.

target:

String

A UI element used to filter data.
Possible values: "headerFilter", "filterBuilder", "search".

Context:

Column

The this keyword refers to the column's configuration.

Return Value:

String

|

Array<any>

|

Function

A filter expression.

App.vue
  • <template>
  • <DxCardView ... >
  • <DxColumn
  • data-field="OrderDate"
  • :calculate-filter-expression="calculateOrderDateFilterExpression"
  • />
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • import DxCardView, { DxColumn, type DxCardViewTypes } from 'devextreme-vue/card-view';
  •  
  • function getOrderDay(rowData: orderObj) {
  • return new Date(rowData.OrderDate).getDay();
  • }
  •  
  • function calculateOrderDateFilterExpression(this: DxCardViewTypes.Column, value, selectedFilterOperations, target) {
  • if (value === 'weekends') {
  • return [[getOrderDay, '=', 0], 'or', [getOrderDay, '=', 6]];
  • }
  • return this.defaultCalculateFilterExpression(value, selectedFilterOperations, target) as any;
  • }
  • </script>

calculateSortValue

Calculates custom values used to sort this column.

Type:

String

|

Function

Function parameters:
cardData:

Object

The data of the card to which the field belongs.

Context:

Column

The this keyword refers to the column's configuration.

Return Value: any

The value to be used in sorting.

This property requires the name of the data source field used for sorting this column or a function to obtain those values. The following code snippet demonstrates the first approach:

App.vue
  • <template>
  • <DxDataGrid ... >
  • <DxColumn
  • data-field="Position" <!-- supplies column values -->
  • calculate-sort-value="isOnVacation" <!-- supplies values used to sort the Position column -->
  • />
  • </DxDataGrid>
  • </template>
  • <script setup lang="ts">
  • import { DxDataGrid, DxColumn } from 'devextreme-vue/data-grid';
  • </script>

The following code snippet uses calculateSortValue to concatenate State and City values for sorting the Employee column:

App.vue
  • <template>
  • <DxDataGrid ... >
  • <DxColumn
  • data-field="Employee"
  • :calculate-sort-value="sortByLocation"
  • />
  • </DxDataGrid>
  • </template>
  • <script setup lang="ts">
  • import { DxDataGrid, DxColumn } from 'devextreme-vue/data-grid';
  •  
  • const sortByLocation = (cardData) => {
  • return cardData.State + cardData.City;
  • }
  • </script>

caption

Specifies a caption for the column.

Type:

String

| undefined

Use this property to display a descriptive or friendly name for the column. If this property is not set, the caption will be generated from the name of the dataField.

customizeText

Customizes text displayed in field values.

Type:

Function

Function parameters:
fieldInfo:

Object

Information on the current field.

Object structure:
Name Type Description
groupInterval

String

|

Number

Indicates how header filter values were combined into groups. Available if target is "headerFilter".

target

String

The UI element where the customizeText function was called: "card", "headerFilter", "search", "filterPanel", or "filterBuilder".

value any

The field value.

valueText

String

The formatted value converted to a string.

groupInterval:

String

|

Number

Indicates how header filter values were combined into groups. Available if target is "headerFilter".

target:

String

The UI element where the customizeText function was called: "card", "headerFilter", "search", "filterPanel", or "filterBuilder".

value: any

The field value.

valueText:

String

The formatted value converted to a string.

Context:

Column

The this keyword refers to the column's configuration.

Return Value:

String

The text the field value should display.

App.vue
  • <template>
  • <DxCardView ... >
  • <DxColumn
  • data-field="Temperature"
  • :customize-text="customizeText"
  • />
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • import 'devextreme/dist/css/dx.fluent.blue.light.css';
  • import { DxCardView, DxColumn } from "devextreme-vue/card-view";
  •  
  • function customizeText(fieldInfo) {
  • return fieldInfo.value + " °C";
  • }
  • </script>

dataField

Binds the column to a field of the dataSource.

Type:

String

| undefined
NOTE

Review the following notes about data binding:

  • If you create an unbound column (use the calculateFieldValue function), specify the columns[].name property instead of dataField.

  • Data field names cannot be equal to this and should not contain the following characters: ., :, [, and ].

  • Column caption is generated from the dataField value. If you want to use a custom caption, specify it in the caption property. Unlike dataField, caption can contain any characters.

dataType

Converts column values to a different data type.

Type:

DataType

| undefined

If data fields have values of one type but need to be another in the UI component, set the correct type in this property.

editorOptions

Configures the default UI component used for editing.

Type: any

falseText

In a boolean column, replaces all false items with a specified text.

Type:

String

Default Value: 'false'
See Also

fieldCaptionTemplate

Specifies a custom template for the field caption.

Type:

template

Template Data:

FieldTemplateData

The field's data.

App.vue
  • <template>
  • <DxCardView ... >
  • <DxColumn ...
  • field-caption-template="captionTemplate"
  • />
  • <template #captionTemplate="{ data }">
  • <div>
  • <i class="dx-icon-errorcircle"></i>
  • <span>{{ data.field.column.caption }}</span>
  • </div>
  • </template>
  • </DxCardView>
  • </template>

fieldTemplate

Specifies a custom template for the field.

Type:

template

Template Data:

FieldTemplateData

The field's data.

View Demo

App.vue
  • <template>
  • <DxCardView ... >
  • <DxColumn ...
  • field-template="progressTemplate"
  • />
  • <template #progressTemplate="{ data }">
  • <DxProgressBar
  • :value="data.field.value"
  • />
  • </template>
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • import { DxCardView, DxColumn } from 'devextreme-vue/card-view';
  • import { DxProgressBar } from 'devextreme-vue/progress-bar';
  •  
  • // ...
  • </script>

fieldValueTemplate

Specifies a custom template for the field value.

Type:

template

Template Data:

FieldTemplateData

The field's data.

View Demo

App.vue
  • <template>
  • <DxCardView ... >
  • <DxColumn
  • data-field="Email"
  • field-value-template="emailTemplate"
  • />
  • <template #emailTemplate="{ data }" >
  • <a :href="`mailto:${data.field.value}`">{{ data.field.text }}</a>
  • </template>
  • </DxCardView>
  • </template>
  •  
  • <script setup lang="ts">
  • import DxCardView, { DxColumn } from 'devextreme-vue/card-view';
  • </script>

filterType

Specifies whether a user changes the current filter by including (selecting) or excluding (clearing the selection of) values. Applies only if headerFilter.visible and allowHeaderFiltering are true.

Type:

FilterType

Default Value: 'include'

This property accepts the following values.

  • include
    Values in the header filter are unselected initially, and a user can select values to apply a filter.
  • exclude
    All values in the header filter are selected initially. A user can deselect values to change the filter.

This property changes when the user clicks the Select all button in the header filter (only if header filter displays plain data):

Select allfilterType / filterValues
Button is not pressedfilterType: "include"
filterValues: null
Button is pressedfilterType: "exclude"
filterValues: null

filterValue

Specifies the filter value.

Type: any | undefined
Default Value: undefined
Raised Events: onOptionChanged

filterValues

Specifies the values in the header filter.

Type:

Array<any>

Raised Events: onOptionChanged

format

Formats a value before it is displayed in a field.

Type:

Format

Default Value: ''

See the format section for information on accepted values.

formItem

Configures the form item that the field produces in the editing state.

NOTE
The component does not check validation rules in the formItem object. Use the columns.validationRules property to customize validation instead.

headerFilter

Specifies data settings for the header filter.

Type:

ColumnHeaderFilter

| undefined

headerItemCssClass

CSS class name applied to header item elements.

Type:

String

headerItemTemplate

Specifies a custom template for the header item.

Type:

template

Template Data:

ColumnTemplateData

The column's data.

name

Specifies the column's unique identifier. If not set in code, this value is inherited from the dataField.

Type:

String

| undefined

This property's value is used to refer to the column in code.

setFieldValue

Specifies a function to be invoked after the user has edited a field value, but before it is saved in the data source.

Type:

Function

Function parameters:
newData:

Object

The data object where new data should be set.

value: any

The input value.

currentCardData:

Object

Accesses the current card data in read-only mode.

Context:

Column

The this keyword refers to the column's configuration.

Return Value: void |

PromiseLike object (jQuery, native, etc)

Return a promise for an asynchronous operation or return nothing.

This function allows you to process user input before it is saved to the data source. It accepts the newData, value, and currentCardData parameters. value is the user input that you should assign to one of the newData fields. Fill the empty newData object with fields whose values should be saved in the current row's data object. You can use the read-only currentCardData parameter to access the current card's data.

App.vue
  • <template>
  • <DxCardView ... >
  • <DxColumn data-field="Price" />
  • <DxColumn data-field="Count" data-type="number" :set-cell-value="setFieldValue" />
  • <DxColumn data-field="TotalPrice" />
  • </DxCardView>
  • </template>
  • <script setup lang="ts">
  • import 'devextreme/dist/css/dx.fluent.blue.light.css';
  • import { DxCardView, DxColumn } from 'devextreme-vue/card-view';
  •  
  • const setFieldValue = (newData, value, currentCardData) => {
  • newData.Count = value;
  • newData.TotalPrice = currentCardData.Price * value;
  • }
  • </script>

showInColumnChooser

Specifies whether the column chooser can contain the column header.

Type:

Boolean

Default Value: true

sortIndex

Specifies the index according to which columns participate in sorting.

Type:

Number

| undefined
Raised Events: onOptionChanged

This property accepts an integer specifying the index of the column in a collection of columns with applied sorting.

sortingMethod

Specifies a custom comparison function for sorting. Applies only when sorting is performed on the client.

Type:

Function

| undefined
Function parameters:
value1: any

A value to be compared.

value2: any

A value to be compared.

Context:

Column

The this keyword refers to the column's configuration.

Return Value:

Number

Specifies whether value1 goes before value2.

This function accepts two cell values and should return a number that indicates their sort order:

  • Less than zero
    value1 goes before value2.
  • Zero
    value1 and value2 remain unchanged relative to each other.
  • Greater than zero
    value1 goes after value2.

The function performs a culture-insensitive string comparison.

sortOrder

Specifies the sort order of column values.

Type:

SortOrder

| undefined
Raised Events: onOptionChanged

Rows initially follow the order of the data source. To change the order, set the sortOrder property to "asc" for ascending or "desc" for descending. For multi-column sorting, set the sortIndex. Without this, sorted columns receive a sort index based on their placement in the columns array.

trueText

In a boolean column, replaces all true items with the specified text.

Type:

String

Default Value: 'true'
See Also

validationRules

Specifies validation rules to be checked when field values are updated.

visible

Specifies whether the column is visible.

Type:

Boolean

Default Value: true
Raised Events: onOptionChanged

visibleIndex

Specifies the position of the column among other columns in the resulting UI component.

Type:

Number

| undefined
Raised Events: onOptionChanged