Fetch records for datatable
Function: Fetch records for datatable
This function allows you to retrieve data from your application's database and display it within a datatable component on your page. You can specify which data to fetch, apply filters to narrow down the results, select specific fields to display, and define the order in which the data should appear.
Input
- UI element (Type: UI element, specifically a Datatable)
- The datatable component on your page that will display the fetched records. This is a required input.
- Data format (Type: Data Format)
- The specific data structure or "table" in your database from which you want to retrieve records. This is a required input.
- Filters (Type: List of Objects)
- A list of conditions that records must meet to be included. All conditions in this list must be true for a record to be fetched (AND relationship).
- Each filter item requires:
- Attribute: The specific field within your chosen Data Format to check.
- Operator: How the attribute should be compared (e.g., "Equal", "Greater than", "Contains").
- Value: The value to compare against the attribute. (This field is hidden if the operator is "Is null" or "Is not null").
- Filters (OR) (Type: List of Objects)
- A list of conditions where at least one condition must be true for a record to be included (OR relationship). These filters are applied in addition to any "Filters" (AND) you define.
- Each filter item requires:
- Attribute: The specific field within your chosen Data Format to check.
- Operator: How the attribute should be compared (e.g., "Equal", "Greater than", "Contains").
- Value: The value to compare against the attribute. (This field is hidden if the operator is "Is null" or "Is not null").
- Attributes (Type: List of Objects)
- A list of specific fields you want to retrieve from the database. If you don't specify any attributes, all fields will be fetched.
- Each attribute item requires:
- Attribute: The specific field you want to retrieve.
- Sort by (Type: List of Objects)
- A list of rules to define the order of the fetched records. You can add multiple sorting rules.
- Each sorting rule requires:
- Attribute: The field by which to sort the records.
- Order: Whether to sort in "Ascending" (A-Z, 0-9) or "Descending" (Z-A, 9-0) order.
- Clear datatable (Type: True/False, Default:
false)- If set to
True, any existing data in the datatable will be removed before the new records are added. IfFalse, the new records will be appended to the existing ones.
- If set to
- Hide the identifier column (Type: True/False, Default:
true)- If set to
True, the unique ID column for each record will not be visible in the datatable. IfFalse, the ID column will be shown.
- If set to
Output
The specified datatable UI element on your page will be updated to display the fetched records according to your filter, attribute, and sorting preferences.
Execution Flow
Real-Life Examples
Example 1: Displaying All Active Customers
Scenario: You want to show a list of all customers who are currently marked as "Active" in your system on your "Customer Dashboard" page.
Inputs:
- UI element:
Customer_Datatable(the datatable component on your Customer Dashboard page) - Data format:
Customers - Filters:
- Item 1:
- Attribute:
Status - Operator:
Equal - Value:
Active
- Attribute:
- Item 1:
- Clear datatable:
True - Hide the identifier column:
True
Result: The Customer_Datatable on your Customer Dashboard page will be cleared, and then populated with all customer records where the Status field is "Active". The unique ID for each customer will not be shown.
Example 2: Listing Products Under a Certain Price, Sorted by Name
Scenario: You need to display products from your "Inventory" that cost less than $50, and you want them listed alphabetically by their name.
Inputs:
- UI element:
Product_List_Datatable(the datatable component on your Products page) - Data format:
Products - Filters:
- Item 1:
- Attribute:
Price - Operator:
Less than - Value:
50
- Attribute:
- Item 1:
- Attributes:
- Item 1:
ProductName - Item 2:
Price - Item 3:
Category
- Item 1:
- Sort by:
- Item 1:
- Attribute:
ProductName - Order:
Ascending
- Attribute:
- Item 1:
- Clear datatable:
True - Hide the identifier column:
False
Result: The Product_List_Datatable will be cleared and then display only the ProductName, Price, and Category for products costing less than $50. These products will be sorted alphabetically by their ProductName, and their unique IDs will be visible.
Example 3: Finding Tasks Assigned to Specific Users or with High Priority
Scenario: You want to see tasks that are either assigned to "John Doe" or "Jane Smith", OR tasks that have a "High" priority, on your "Task Overview" page.
Inputs:
- UI element:
Task_Datatable(the datatable component on your Task Overview page) - Data format:
Tasks - Filters (OR):
- Item 1:
- Attribute:
AssignedTo - Operator:
Equal - Value:
John Doe
- Attribute:
- Item 2:
- Attribute:
AssignedTo - Operator:
Equal - Value:
Jane Smith
- Attribute:
- Item 3:
- Attribute:
Priority - Operator:
Equal - Value:
High
- Attribute:
- Item 1:
- Clear datatable:
True - Hide the identifier column:
True
Result: The Task_Datatable will be cleared and then display all tasks where the AssignedTo field is "John Doe" or "Jane Smith", or where the Priority field is "High". The unique task IDs will not be shown.