cardView().mode()

Since: CardView 1.0.0

Get / set the mode CardView is operating in.
Please note - this property requires the CardView extension for DataTables.

Description

This method is used to control the operating mode of CardView, and thus whether the cards or table are shown. CardView has three operating mode:

  • cards - Cards are displayed
  • table - Table is displayed
  • auto - Either the cards or table will be displayed based on the content width available and the responsive configuration of CardView.

Due to the auto mode, the cardView().displayed() method is also available to be able to definitively know which display method is being used at any specific time.

Types

cardView().mode()

Get the current operating mode of CardView.

Returns:

string or null:
The current operating mode. Will be one of cards, table or auto. null will be given if CardView is not active on the target table.

cardView().mode( set )

Set the operating mode of CardView.

Parameters:

Returns:

DataTable.Api:
The original API instance is returned for easy chaining of methods.

Example

Immediately set the operating mode when the table is initialised:

let table = new DataTable('#myTable', {
	cardView: true
});

table.cardView().mode('cards');