▦K2 Advanced GridsDeveloper Portal / 0.24
Documentation / Advanced interaction

Card view

Transform the same K2 ListView into a responsive collection of business cards, retaining the native record selection, K2 Rules, filtering, pagination and grouping.

Before you begin

Continue from Lesson 12 — Row Context Menus. Use the existing Purchase Orders List and native View Details Toolbar Button (ViewDetails_ToolBarButton). Keep the Description and Expected Delivery Date columns in the underlying ListView even when hidden in the table.

Download basic configuration ↓ Download compact configuration ↓ Download actions configuration ↓ Download grouped configuration ↓ Download preferences configuration ↓
Required after saving a configuration file

Replace REPLACE_WITH_YOUR_AREAITEMID with your runtime Area Item ID, save the chosen file as purchase-orders.config.js, increment configVersion in the Data Label loader and reload. The engine is unchanged. Console changes are temporary. Use the appropriate full configuration for each exercise; do not replace the entire defaults object with a fragment.

1. Enable Card View

Start with the basic configuration. Table is the initial mode; select Cards in the toolbar to render the same records as cards. The native column headers remain available for filtering, sorting and grouping.

K2AdvancedGridsConfig.defaults.cardView = {
    "enabled": true,
    "defaultMode": "table",
    "allowUserSwitch": true,
    "showToolbarButton": true,
    "layout": {
        "columns": "auto",
        "minCardWidth": 280,
        "maxCardWidth": 450,
        "gap": 12,
        "density": "comfortable"
    },
    "mapping": {
        "title": "Vendor Name",
        "subtitle": "Order Number",
        "body": "Description",
        "footer": "Expected Delivery Date",
        "linkText": "View Details",
        "linkButton": "ViewDetails_ToolBarButton",
        "linkUrlColumn": null
    },
    "fields": [
        {
            "column": "Department",
            "label": "Department"
        },
        {
            "column": "Order Amount",
            "label": "Order Amount",
            "format": "number",
            "precision": 2
        },
        {
            "column": "Status",
            "label": "Status",
            "format": "badge"
        },
        {
            "column": "Is Approved",
            "label": "Approved",
            "format": "badge"
        },
        {
            "column": "Is Urgent",
            "label": "Urgent",
            "format": "badge"
        },
        {
            "column": "Delivery Progress",
            "label": "Delivery Progress"
        }
    ],
    "preserveInPreferences": true
};
K2AdvancedGrids.instance.refresh();
Original table mode
Figure 109 · Original table mode · Actual K2 Runtime capture
Basic card layout
Figure 110 · Basic card layout · Actual K2 Runtime capture

2. Selection and field mapping

Click a card to select its underlying K2 row. The blue outline identifies the selected record. Mapping assigns Vendor Name to title, Order Number to subtitle, Description to body and Expected Delivery Date to footer. The fields array controls the additional labeled values and their formats. An empty description may be omitted.

Selected card and native toolbar
Figure 111 · Selected card and native toolbar · Actual K2 Runtime capture

3. Layout and responsive behavior

Use the compact configuration for three columns and compact density. The automatic layout adapts to the available width; test by narrowing the browser window.

Object.assign(K2AdvancedGridsConfig.defaults.cardView.layout, {columns: 3, density: "compact"});
K2AdvancedGrids.instance.refresh();
Three-column compact layout
Figure 112 · Three-column compact layout · Actual K2 Runtime capture
Object.assign(K2AdvancedGridsConfig.defaults.cardView.layout, {columns: "auto", density: "comfortable"});
K2AdvancedGrids.instance.refresh();
Single-column layout in a narrow viewport
Figure 113 · Single-column layout in a narrow viewport · Actual K2 Runtime capture

4. Status and Boolean badges

Load the actions configuration for colored status badges. Card fields can use the badge format; status styling is supplied by conditional formatting rules. See Lesson 8 — Boolean Formatting and Conditional Formatting. Without status rules the badges are neutral. The example uses generic Yes/No colors for Boolean fields, not semantic urgency colors.

Colored status and Boolean badges
Figure 114 · Colored status and Boolean badges · Actual K2 Runtime capture

5. Native K2 actions

Click View Details on the Cedar Consulting card. The configured linkButton invokes the existing native Toolbar Button rule for the selected row. The message confirms Order Number PO-2026-00002. Right-click a card to open the same row context menu as in Lesson 12.

Native K2 rule receives the correct order number
Figure 115 · Native K2 rule receives the correct order number · Actual K2 Runtime capture
Context menu on a cancelled order
Figure 116 · Context menu on a cancelled order · Actual K2 Runtime capture
Conditional availability on an approved order
Figure 117 · Conditional availability on an approved order · Actual K2 Runtime capture
Security boundary

Card links and menu conditions are presentation features. Validate authorization and business state in K2 Rules and backend services. The examples do not execute real cancellation.

6. Filtering and pagination

Filter Status to Overdue and Is Urgent to Yes using the column headers. Expect 50 matching orders, total value 5,940,175.22, average 118,803.50 and budget variance 2,603.60. Navigate to page 2; the filtered KPI values stay unchanged while the cards change. See Lesson 2, Lesson 3 and Lesson 4.

Filtered cards and recalculated KPIs
Figure 118 · Filtered cards and recalculated KPIs · Actual K2 Runtime capture
Next page of filtered cards
Figure 119 · Next page of filtered cards · Actual K2 Runtime capture

7. Grouped cards

Load the grouped configuration. The Department group headers show record counts and aggregates; use Expand all, Collapse all or individual arrows. Apply an Order Amount between 40000 and 50000 to reproduce the filtered example, then expand IT. For nested grouping clear the filters, add Status as a second grouping column and collapse Pending Approval while leaving Overdue expanded. See Lesson 11 — Row Grouping.

Cards grouped by Department
Figure 120 · Cards grouped by Department · Actual K2 Runtime capture
Filtered groups with individual expansion states
Figure 121 · Filtered groups with individual expansion states · Actual K2 Runtime capture
K2AdvancedGridsConfig.defaults.rowGrouping.columns = ["Department", "Status"];
K2AdvancedGrids.instance.refresh();
Nested Department and Status groups
Figure 122 · Nested Department and Status groups · Actual K2 Runtime capture

8. Persist the selected view

Load the preferences configuration, which uses a dedicated namespace and starts in table mode. Select Cards and reload the form. The diagnostic should report cards mode and restored preferences. Storage is local to the browser; see Lesson 7 — Personal Preferences.

Restored card presentation
Figure 123 · Restored card presentation · Actual K2 Runtime capture
console.table(K2AdvancedGrids.instance.inspect().map(g => ({
  areaItemId: g.id,
  mode: g.cardView.mode,
  cards: g.cardView.cards,
  loadedRows: g.rows,
  preferencesEnabled: g.preferences.enabled,
  preferencesStatus: g.preferences.status
})));
Diagnostics: cards mode, 10 cards, 250 loaded rows, preferences restored
Figure 124 · Diagnostics: cards mode, 10 cards, 250 loaded rows, preferences restored · Actual K2 Runtime capture

Configuration reference

ParameterMeaning
enabledEnable Card View
defaultModetable or cards
allowUserSwitch / showToolbarButtonAllow mode switching and show toolbar selector
layout.columnsauto or a configured column count
layout.minCardWidth / maxCardWidthCard width bounds
layout.gap / densitySpacing and comfortable or compact density
mapping.title / subtitle / body / footerSource column names for card regions
mapping.linkText / linkButtonLink label and native Toolbar Button name
mapping.linkUrlColumnOptional source column for a URL link
fieldsOrdered additional field definitions: column, label, format and precision where applicable
preserveInPreferencesSave selected mode when preferences are enabled

Benefits and current limitations

Cards offer a readable alternative to a wide table without duplicating the underlying K2 business logic. They operate on loaded records, not a separate server query. Table-specific data bars and color scales are not shown inside cards in this release. Table headers remain visible to provide access to column operations. Optional header hiding, card footer alignment and improved field layout are deferred until after the first documentation release. The engine remains frozen except for blocking defects.

Reset

Switch to Table or disable Card View. A saved preference can override the initial mode when the feature is enabled; reset grid preferences if necessary.

K2AdvancedGridsConfig.defaults.cardView.enabled = false;
K2AdvancedGrids.instance.refresh();
Enlarged screenshot