Add list of objects to datatable
Function: Add list of objects to datatable
This function allows you to quickly populate a visual table (Datatable) in your application with a collection of data records. It's perfect for displaying lists of items like customer records, product inventories, or task lists directly from your data sources.
Input
- UI element (Datatable): This is the specific visual table component on your application page where you want to add the data. You'll select it from a list of available Datatable elements.
- Objects (List of Objects): This is the collection of data records you want to display in your table. Each "object" represents a row in your table, and its properties (like "name," "price," "status") will become the columns.
- Clear datatable (True/False):
- If set to
True, the function will first remove all existing data from the selected Datatable before adding the new objects. - If set to
False(default), the new objects will be added to the end of the existing data in the Datatable.
- If set to
- Hide the identifier column (True/False):
- If set to
True(default), a column containing unique identifiers for each data record (often called 'ID') will be hidden from view in the Datatable. - If set to
False, this identifier column will be visible.
- If set to
Output
This function does not produce a direct output value. Instead, it modifies the content of the selected Datatable UI element on your application page.
Execution Flow
Real-Life Examples
Example 1: Displaying a list of new customer sign-ups
Imagine you have a list of new customers who signed up today, and you want to display them in a "New Customers" table on your dashboard.
- Inputs:
- UI element (Datatable):
New Customers Table - Objects (List of Objects):
[ \{ "Name": "Alice Smith", "Email": "alice@example.com", "Date Joined": "2023-10-26" \}, \{ "Name": "Bob Johnson", "Email": "bob@example.com", "Date Joined": "2023-10-26" \} ] - Clear datatable:
True - Hide the identifier column:
True
- UI element (Datatable):
- Result: The "New Customers Table" on your dashboard will be cleared, and then populated with two rows: one for Alice Smith and one for Bob Johnson, showing their name, email, and join date. The internal ID column for these customers will not be visible.
Example 2: Adding new products to an existing inventory list
You've just received a new shipment of products and want to add them to your "Product Inventory" table without removing the products already listed.
- Inputs:
- UI element (Datatable):
Product Inventory Table - Objects (List of Objects):
[ \{ "Product Name": "Wireless Mouse", "SKU": "WM-001", "Price": 25.99, "Stock": 150 \}, \{ "Product Name": "Mechanical Keyboard", "SKU": "MK-005", "Price": 89.99, "Stock": 75 \} ] - Clear datatable:
False - Hide the identifier column:
True
- UI element (Datatable):
- Result: The "Product Inventory Table" will retain all its current product listings, and two new rows will be appended to the bottom: "Wireless Mouse" and "Mechanical Keyboard," along with their details. The ID column will remain hidden.
Example 3: Showing a list of urgent tasks, including their unique IDs for reference
Your team needs to see a list of urgent tasks, and for debugging or cross-referencing purposes, they also need to see the unique task ID.
- Inputs:
- UI element (Datatable):
Urgent Tasks List - Objects (List of Objects):
[ \{ "ID": "TASK-001", "Description": "Fix login bug", "Assigned To": "John", "Due Date": "2023-10-27" \}, \{ "ID": "TASK-002", "Description": "Review new feature", "Assigned To": "Jane", "Due Date": "2023-10-28" \} ] - Clear datatable:
True - Hide the identifier column:
False
- UI element (Datatable):
- Result: The "Urgent Tasks List" will be cleared and then display two tasks. Each row will show the "ID", "Description", "Assigned To", and "Due Date" columns, making the unique task identifiers visible to the user.