React 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.
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.
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.
The data object's key.
The data object.
defaultOptions(rule)
Specifies the device-dependent default configuration properties for this component.
The component's default device properties.
Name | Type | Description |
---|---|---|
device | | |
Device parameters. |
options |
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
DevExpress.ui.dxCardView.defaultOptions({ device: { deviceType: "desktop" }, options: { // Here go the CardView properties } });
Angular
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
const devicesConfig = [ { deviceType: 'desktop' }, { deviceType: 'tablet' }, { deviceType: 'phone' }, ]; devicesConfig.forEach(deviceConfig => { DevExpress.ui.dxCardView.defaultOptions({ device: deviceConfig, options: { // Here go the CardView properties } }); });
Angular
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> ) }
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.
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:
$("#myCardView").dxCardView("dispose"); $("#myCardView").remove();
Angular
Use conditional rendering instead of this method:
<dx-card-view ... *ngIf="condition"> </dx-card-view>
Vue
Use conditional rendering instead of this method:
<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:
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.
The card index.
element()
Gets the root UI component element.
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
getCardElement(cardIndex)
Gets the container of a card with a specific index.
The card's index.
The card's container.
getCardIndexByKey(key)
Gets the index of a card with a specific key.
The card's key.
The card's index; -1 if nothing found.
getCombinedFilter()
Gets the total filter that combines all the filters applied.
A filter expression.
getDataSource()
Gets the DataSource instance.
The DataSource instance.
getInstance(element)
Gets the instance of a UI component found using its DOM node.
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.
The card's index.
The card's key; undefined if nothing found.
getScrollable()
Gets the instance of the UI component's scrollable part.
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.
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.
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.
See Also
hasEditData()
Checks whether the UI component has unsaved changes.
true
if the UI component has unsaved changes; otherwise - false
.
instance()
Gets the UI component's instance. Use it to access other methods of the UI component.
This UI component's instance.
See Also
isCardSelected(key)
Checks whether a card with a specific key is selected.
The card's key.
true
if the card is selected; otherwise false
.
keyOf(obj)
Gets a data item's key value.
A data item.
The data item's key value.
off(eventName)
Detaches all event handlers from a single event.
The event's name.
The object for which this method is called.
See Also
off(eventName, eventHandler)
Detaches a particular event handler from a single event.
The object for which this method is called.
See Also
on(eventName, eventHandler)
Subscribes to an event.
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.
Events with their handlers: { "eventName1": handler1, "eventName2": handler2, ...}
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(optionName)
Gets the value of a single property.
The property's name or full path.
This property's value.
See Also
option(options)
Updates the values of several properties.
Options with their new values.
See Also
pageIndex(value)
Switches the UI component to a specific page using a zero-based index.
The zero-based page index.
registerKeyHandler(key, handler)
Registers a handler to be executed when a user presses a specific key.
A key.
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.
See Also
- reload() in DataSource | List
- refresh() in DataGrid | TreeList
resetOption(optionName)
Resets a property to its default value.
A property's name.
See Also
searchByText(text)
Searches for a string in columns whose allowSearch property is true
.
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.
This method clears selected rows. To maintain their selection, use true
as the second argument.
cardViewInstance.selectRows([5, 10, 12], true);
If DataGrid's key is composite (for example, key: ['id', 'name']
), call the method like this:
cardViewInstance.selectRows([ { id: 5, name: 'Alex' }, { id: 10: name: 'Bob' } ], true);
If you have technical questions, please create a support ticket in the DevExpress Support Center.