JavaScript/jQuery CardView Methods

addCard()

Adds an empty card and switches it to the editing state.

Use this method if you want to add an empty card.

This method operates when paging.enabled is set to false, or when dataSource.reshapeOnPush is true and remoteOperations is false.

beginCustomLoading(text)

Displays the load panel.

Parameters:
text:

String

The text for the load panel to display.

The load panel opens automatically when the UI component processes or retrieves data. To open the load panel manually, call this method. Without an argument, this method displays text from the loadPanel.text property. Customize the load panel through the loadPanel configuration. When opened manually, the load panel remains visible until endCustomLoading() is called.

NOTE
Manually opening the load panel does not replace the automatic panel, which may cause unexpected text changes as the automatic panel overrides the manual panel. Ensure text consistency when manually opening the load panel.
See Also

beginUpdate()

Postpones rendering that can negatively affect performance until the endUpdate() method is called.

The beginUpdate() and endUpdate() methods reduce the number of renders in cases where extra rendering can negatively affect performance.

See Also

byKey()

Gets a data object with a specific key.

Parameters:
key: any

The data object's key.

Return Value: any

The data object.

cancelEditData()

Discards changes that a user made to data.

clearFilter()

Clears all filters applied to UI component cards.

clearSelection()

Clears selection of all cards on all pages.

clearSorting()

Clears sorting settings of all columns.

defaultOptions(rule)

Specifies the device-dependent default configuration properties for this component.

Parameters:
rule:

Object

The component's default device properties.

Object structure:
Name Type Description
device

Device

|

Function

Device parameters.
When you specify a function, get information about the current device from the argument. Return true if the properties should be applied to the device.

options

Object

Options to be applied.

defaultOptions is a static method that the UI component class supports. The following code demonstrates how to specify default properties for all instances of the CardView UI component in an application executed on the desktop.

jQuery
JavaScript
DevExpress.ui.dxCardView.defaultOptions({ 
    device: { deviceType: "desktop" },
    options: {
        // Here go the CardView properties
    }
});
Angular
TypeScript
import CardView, { Properties } from "devextreme/ui/card_view";
// ...
export class AppComponent {
    constructor () {
        CardView.defaultOptions<Properties>({
            device: { deviceType: "desktop" },
            options: {
                // Here go the CardView properties
            }
        });
    }
}
Vue
<template>
    <div>
        <DxCardView id="cardView1" />
        <DxCardView id="cardView2" />
    </div>
</template>
<script>
import DxCardView from "devextreme-vue/card-view";
import CardView from "devextreme/ui/card_view";

CardView.defaultOptions({
    device: { deviceType: "desktop" },
    options: {
        // Here go the CardView properties
    }
});

export default {
    components: {
        DxCardView
    }
}
</script>
React
import dxCardView from "devextreme/ui/card_view";
import CardView from "devextreme-react/card-view";

dxCardView.defaultOptions({
    device: { deviceType: "desktop" },
    options: {
        // Here go the CardView properties
    }
});

export default function App() {
    return (
        <div>
            <CardView id="cardView1" />
            <CardView id="cardView2" />
        </div>
    )
}

You can also set rules for multiple device types:

jQuery
JavaScript
const devicesConfig = [
    { deviceType: 'desktop' },
    { deviceType: 'tablet' },
    { deviceType: 'phone' },
];

devicesConfig.forEach(deviceConfig => {
    DevExpress.ui.dxCardView.defaultOptions({ 
        device: deviceConfig,
        options: {
            // Here go the CardView properties
        }
    });
});
Angular
TypeScript
import CardView, { Properties } from "devextreme/ui/card_view";
// ...
export class AppComponent {
    constructor () {
        const devicesConfig = [
            { deviceType: 'desktop' },
            { deviceType: 'tablet' },
            { deviceType: 'phone' },
        ];

        devicesConfig.forEach(deviceConfig => {
            CardView.defaultOptions<Properties>({
                device: deviceConfig,
                options: {
                    // Here go the CardView properties
                }
            });
        });
    }
}
Vue
<template>
    <div>
        <DxCardView />
    </div>
</template>
<script>
import DxCardView from "devextreme-vue/card-view";
import CardView from "devextreme/ui/card_view";

const devicesConfig = [
    { deviceType: 'desktop' },
    { deviceType: 'tablet' },
    { deviceType: 'phone' },
];

devicesConfig.forEach(deviceConfig => {
    CardView.defaultOptions({
        device: deviceConfig,
        options: {
            // Here go the CardView properties
        }
    });
});

export default {
    components: {
        DxCardView
    }
}
</script>
React
import dxCardView from "devextreme/ui/card_view";
import CardView from "devextreme-react/card-view";

const devicesConfig = [
    { deviceType: 'desktop' },
    { deviceType: 'tablet' },
    { deviceType: 'phone' },
];

devicesConfig.forEach(deviceConfig => {
    dxCardView.defaultOptions({
        device: deviceConfig,
        options: {
            // Here go the CardView properties
        }
    });
});

export default function App() {
    return (
        <div>
            <CardView />
        </div>
    )
}

deleteCard(cardIndex)

Removes a card with a specific index.

Parameters:
cardIndex:

Number

The card index.

deselectAll()

Clears the selection of all cards on all pages or the currently rendered page only.

The value of the selectAllMode property determines whether this method clears selections from all cards across all pages or only from visible pages. If a filter is in effect, selections clear only from cards that match filter conditions. To clear all selections regardless selectAllMode or filters, use the clearSelection() method.

deselectCards(keys)

Cancels the selection of cards with specific keys.

Parameters:
keys:

Array<any>

The card keys.

dispose()

Disposes of all the resources allocated to the CardView instance.

jQuery

After calling this method, remove the DOM element associated with the UI component:

JavaScript
$("#myCardView").dxCardView("dispose");
$("#myCardView").remove();
Angular

Use conditional rendering instead of this method:

app.component.html
<dx-card-view ...
    *ngIf="condition">
</dx-card-view>
Vue

Use conditional rendering instead of this method:

App.vue
<template>
    <DxCardView ...
        v-if="condition">
    </DxCardView>
</template>

<script>
import DxCardView from 'devextreme-vue/card-view';

export default {
    components: {
        DxCardView
    }
}
</script>
React

Use conditional rendering instead of this method:

App.js
import React from 'react';

import CardView from 'devextreme-react/card-view';

function DxCardView(props) {
    if (!props.shouldRender) {
        return null;
    }

    return (
        <CardView ... >    
        </CardView>
    );
}

class App extends React.Component {
    render() {
        return (
            <DxCardView shouldRender="condition" />
        );
    }
}
export default App;

editCard(cardIndex)

Switches a card with a specific index to the editing state.

Parameters:
cardIndex:

Number

The card index.

element()

Gets the root UI component element.

Return Value:

HTMLElement | jQuery

An HTML element or a jQuery element when you use jQuery.

See Also

endCustomLoading()

Hides the load panel.

CardView hides the load panel automatically when data is ready. If you used the beginCustomLoading(text) method to display the load panel, call the endCustomLoading() method to remove it.

See Also

endUpdate()

Refreshes the UI component after a call of the beginUpdate() method.

The beginUpdate() and endUpdate() methods reduce the number of renders in cases where extra rendering can negatively affect performance.

See Also

focus()

Sets focus on the UI component.

See Also

getCardElement(cardIndex)

Gets the container of a card with a specific index.

Parameters:
cardIndex:

Number

The card's index.

Return Value:

HTMLElement | jQuery

The card's container.

getCardIndexByKey(key)

Gets the index of a card with a specific key.

Parameters:
key: any

The card's key.

Return Value:

Number

The card's index; -1 if nothing found.

getCombinedFilter()

Gets the total filter that combines all the filters applied.

Return Value: any

A filter expression.

getDataSource()

Gets the DataSource instance.

Return Value:

DataSource

The DataSource instance.

NOTE
This method returns the DataSource instance even if the UI component's dataSource property was given a simple array.

getInstance(element)

Gets the instance of a UI component found using its DOM node.

Parameters:
element:

Element

|

jQuery

The UI component's container.

Return Value:

Object

The UI component's instance.

getInstance is a static method that the UI component class supports. The following code demonstrates how to get the CardView instance found in an element with the myCardView ID:

// Modular approach
import CardView from "devextreme/ui/card_view";
...
let element = document.getElementById("myCardView");
let instance = CardView.getInstance(element) as CardView;

// Non-modular approach
let element = document.getElementById("myCardView");
let instance = DevExpress.ui.dxCardView.getInstance(element);
See Also

getKeyByCardIndex(cardIndex)

Gets the key of a card with a specific index.

Parameters:
cardIndex:

Number

The card's index.

Return Value: any

The card's key; undefined if nothing found.

getScrollable()

Gets the instance of the UI component's scrollable part.

Return Value:

Scrollable

The scrollable part's instance.

For information on API members of the scrollable part, refer to the ScrollView section. The list below shows ScrollView members that are unavailable for this method.

Properties:

  • pullingDownText
  • pulledDownText
  • refreshingText
  • reachBottomText
  • onPullDown
  • onReachBottom

Methods:

  • release(preventScrollBottom)
  • refresh()
See Also

getSelectedCardKeys()

Gets the selected card keys.

Return Value:

Array<any>

Keys of selected cards. The keys are stored in the order the user selects cards.

The whole data object becomes a key if no field is specified in the data source for keys. This method then retrieves data objects similar to the getSelectedCardsData().

getSelectedCardsData()

Gets the selected cards' data objects.

Return Value:

Array<any>

The selected cards' data objects.
The objects are not processed by the DataSource and have the same order in which the cards were selected.

getVisibleCards()

Gets currently rendered cards.

Return Value:

Array<CardInfo>

Currently rendered cards.

hasEditData()

Checks whether the UI component has unsaved changes.

true if the UI component has unsaved changes; otherwise - false.

hideColumnChooser()

Hides the column chooser.

instance()

Gets the UI component's instance. Use it to access other methods of the UI component.

Return Value: CardView

This UI component's instance.

See Also

isCardSelected(key)

Checks whether a card with a specific key is selected.

Parameters:
key: any

The card's key.

Return Value:

Boolean

true if the card is selected; otherwise false.

keyOf(obj)

Gets a data item's key value.

Parameters:
obj: any

A data item.

Return Value: any

The data item's key value.

off(eventName)

Detaches all event handlers from a single event.

Parameters:
eventName:

String

The event's name.

Return Value: CardView

The object for which this method is called.

See Also

off(eventName, eventHandler)

Detaches a particular event handler from a single event.

Parameters:
eventName:

String

The event's name.

eventHandler:

Function

The event's handler.

Return Value: CardView

The object for which this method is called.

See Also

on(eventName, eventHandler)

Subscribes to an event.

Parameters:
eventName:

String

The event's name.

eventHandler:

Function

The event's handler.

Return Value: CardView

The object for which this method is called.

Use this method to subscribe to one of the events listed in the Events section.

See Also

on(events)

Subscribes to events.

Parameters:
events:

Object

Events with their handlers: { "eventName1": handler1, "eventName2": handler2, ...}

Return Value: CardView

The object for which this method is called.

Use this method to subscribe to several events with one method call. Available events are listed in the Events section.

See Also

option()

Return Value:

Object

The UI component's properties.

option(optionName)

Gets the value of a single property.

Parameters:
optionName:

String

The property's name or full path.

Return Value: any

This property's value.

option(optionName, optionValue)

Updates the value of a single property.

Parameters:
optionName:

String

The property's name or full path.

optionValue: any

This property's new value.

option(options)

Updates the values of several properties.

Parameters:
options:

Object

Options with their new values.

pageCount()

Gets the total page count.

Return Value:

Number

The total page count.

pageIndex()

Gets the current page index.

Return Value:

Number

The current page index.

pageIndex(value)

Switches the UI component to a specific page using a zero-based index.

Parameters:
value:

Number

The zero-based page index.

pageSize()

Gets the current page size.

Return Value:

Number

The current page size.

pageSize(value)

Sets the page size.

Parameters:
value:

Number

The page size.

registerKeyHandler(key, handler)

Registers a handler to be executed when a user presses a specific key.

Parameters:
key:

String

A key.

handler:

Function

A handler. Accepts the keydown event as the argument. It is a EventObject or a jQuery.Event when you use jQuery.

The key argument accepts one of the following values:

  • "backspace"
  • "tab"
  • "enter"
  • "escape"
  • "pageUp"
  • "pageDown"
  • "end"
  • "home"
  • "leftArrow"
  • "upArrow"
  • "rightArrow"
  • "downArrow"
  • "del"
  • "space"
  • "F"
  • "A"
  • "asterisk"
  • "minus"

A custom handler for a key cancels the default handler for this key.

See Also

repaint()

Renders the component again without reloading data. Use the method to update the component's markup and appearance dynamically.

The repaint() method re-initializes the component with new settings, resetting its state and history.

View on GitHub

See Also

resetOption(optionName)

Resets a property to its default value.

Parameters:
optionName:

String

A property's name.

See Also

saveEditData()

Saves changes that a user made to data.

searchByText(text)

Searches for a string in columns whose allowSearch property is true.

Parameters:
text:

String

A search string. Pass an empty string to clear search results.

selectAll()

Selects all cards.

Depending on the value of the selectAllMode property, this method selects all cards on all pages or rendered pages only. If a filter is applied, this method selects only those cards that meet the filtering conditions.

selectCards(keys, preserve)

Selects cards with specific keys.

Parameters:
keys:

Array<any>

The card keys.

preserve:

Boolean

Specifies whether selected cards should remain selected.

This method clears selected rows. To maintain their selection, use true as the second argument.

JavaScript
cardViewInstance.selectRows([5, 10, 12], true);

If DataGrid's key is composite (for example, key: ['id', 'name']), call the method like this:

JavaScript
cardViewInstance.selectRows([ { id: 5, name: 'Alex' }, { id: 10: name: 'Bob' } ], true);

showColumnChooser()

Shows the column chooser.

totalCount()

Gets the total card count.

Return Value:

Number

The total card count.