top of page
OmniStudioFactBg.png
Search

How to enable grouping and pagination in a Flexcard Datatable?

  • Writer: Gayathiri Mohan
    Gayathiri Mohan
  • Feb 8, 2024
  • 3 min read

A datatable element in Flexcard is used to fetch the data from a data source and display it in a tabular structure.


In this article, let us see how to enable grouping and pagination in the Datatable element of a Flexcard.


Create a new Flexcard, and from the ‘Setup’ tab, add a data source to fetch the records to be displayed in the datatable.

ree

In the example, a data source of type DataRaptor is added, and an Extract Dataraptor ‘DRGetCaseDetails’ is added.


In the Input Map section, add a new ‘Key-Value’ pair. 


Key holds the variable to be passed to the data source. Value holds the value of the variable.


Here, Key : AccountId and Value : {recordId}.


Click ‘Save & Fetch’ in the datasource.


When the Flexcard is added to a lightning record page, the record Id of the record will be automatically stored in the global context variable {recordId} and passed via AccountId to the data source.


The dataraptor DRGetCaseDetails retrieves the details of all the Cases linked to an Account (based on the AccountId passed).


ree

ree

Disable the Repeat Records checkbox.

ree

Now add a datatable element to the Flexcard.

ree

The datatable automatically shows data from the added data source.


ree

Optionally, in the Datatable Properties section, click Column to modify the behavior of the datatable columns based on the need.

ree
ree

In this example,

  • The order of columns (CaseNumber and Subject) is modified. 

  • The Field Label attribute of the column CaseNumber is updated to Case Number. This displays the new column label in the datatable UI.

  • The Is Visible attribute of the column Id is set to False. This hides the column in the datatable UI.


ree


Enable Grouping:

In the Group Attributes section of Datatable Properties, we can configure the attributes to group the datatable rows.

ree

Group By: This attribute allows the datatable rows to be grouped together based on one particular column (field).

ree

In this example, Priority is entered in the Group By field. This groups the Case records based on the Priority field values: High, Medium, and Low.


ree

Group Order: It sorts groups in ascending or descending order. By default, the sort order is ‘Ascending’. It can be changed to ‘Descending’ if needed.

ree

Here, the Group Order is set to Descending, and so the groupings are displayed in descending order as Medium, Low, and High.


ree

Active Groups: This expands all groups if enabled. If disabled, all the groups will be collapsed by default, and user can expand the groups manually when needed.

ree

In this example, since the ‘Active Groups’ checkbox is disabled, by default all the groups are collapsed.

ree

When the user clicks a particular group, the corresponding rows are expanded.

ree

On enabling the ‘Active Groups’ checkbox, all the groups are expanded by default, as shown below.

ree

Hide Extra Column: This attribute removes the extra column that holds the group values when enabled.

ree

In this example, the extra column holding the group values is removed, and the group values directly appear in the first column.

ree

Sort Across Groups: When enabled, this attribute sorts both the groups and the rows within each group when the column header is clicked. When disabled, sorting happens only within each group when the column header is clicked.

ree

In this example, the checkbox is enabled, and now when the ‘Case Number’ column header is clicked to sort in descending order, first the groups will be sorted in descending order as Medium, Low, and High.

And then the rows within each group will be sorted in descending order, as shown below.


ree

Now, when the checkbox is disabled and the ‘Case Number’ column header is clicked to sort in descending order, only the rows within the group will be sorted in descending order, and the groups are not impacted.


ree


Enable Pagination:

In the Attributes section of the Datatable Properties, we can set the pagination attributes.


ree

Page Size: This attribute allows us to set the number of records to be displayed on each page of the datatable.


In this example, Page Size is set to 5 and there are six Case records linked to the Account. Hence, two pages are created: the first page contains the first five records, and the second page contains the sixth record.


ree
ree

This behavior is applicable only if the ‘Page Size’ attribute is set but the ‘Group By’ attribute is not set in the datatable.


If both the ‘Page Size’ and the ‘Group By’ attributes are set, then the ‘Page Size’ is determined by the number of groups instead of the number of rows 

in the datatable.

ree
ree

In this example, since both attributes are set, the datatable shows two groups and the corresponding rows on the first page, and the third group rows on the second page.

ree
ree

Page Limit: This attribute allows us to limit the number of pages displayed in the datatable. To use this attribute, the ‘Page Size’ attribute must be set.

ree
ree

In this example, Page Size is set to 3, and Page Limit is set to 1. Though there are six Case records, only the first page with three records will be displayed in the datatable.


ree

References:



 
 
 

Recent Posts

See All
OmniStudioFactFooterBg.png
logo.png

OmniStudiofacts helps us to build a Vlocity/OmniStudio Tech Community which focuses on sharing technical skills and experience across the globe.

© 2023 by OmniStudioFacts.

bottom of page