Table Properties
The Table component displays and manages data, connecting seamlessly with databases and APIs. It allows users to view and edit data directly within the table. This document goes through all the properties related to the Table component.
![ToolJet - Component Reference - Table Preview](/img/widgets/table/table-preview-v2.png)
Data
To populate the Table with data, you need to provide the data in the form of an array of objects under its Data
property. You can utilize data from queries by referring query data to populate the Table.
The Table component will automatically generate all the required columns when the data is provided. The Table also loads one level of nested data.
Example - Passing an array:
{{[{ id: 1, name: 'Sarah', email: '[email protected]', contact:{number: 8881212, address: '25, Huntley Road, Newark'} }]}}
Example - Passing a query data:
{{queries.restapi1.data}}
//replace restapi1 with your query name
Columns
Go to the columns section to read more about columns.
Any property having fx button next to its field can be programmatically configured.
Action Buttons
![ToolJet - Component Reference - Actions](/img/widgets/table/action-v2.png)
Action buttons are positioned in the Table's final column. These buttons' appearance can be customized, and specific actions can be defined for when they are clicked using the On click
action. Upon clicking an action button, the selectedRow
exposed variable of the Table is updated to reflect the data of the selected row.
Below are the button text properties that you can set.
Property | Description |
---|---|
Button text | Sets the text that you want to be displayed on the action button. |
Button position | Sets the button position to left or right. |
Background color | Sets the background color of the action button. |
Text color | Sets the color of button-text of the action button. |
Disable Action Button | Toggle on to disable the action button. You can programmatically set its value by clicking on the fx button next to it, if set to {{true}} , the action button will be disabled and becomes non-functional. By default, its value is set to {{false}} . |
New event handler | The New event handler button lets you create an event handler to define behavior for action buttons based on the On click action. |
Events
You can trigger a range of events on the Table component.
- Row hovered
- Row clicked
- Save changes
- Page changed
- Search
- Cancel changes
- Sort applied
- Cell value changed
- Filter changed
- Add new rows
Row hovered
This event is activated when the mouse pointer hovers over a row. The hoveredRowId
variable captures the ID of the hovered row, and the hoveredRow
variable stores the row's data in object format.
Row clicked
This event is triggered when a Table row is clicked. The selectedRowId
and selectedRow
exposed variables of the Table store the ID and data of the selected row, respectively.
Save changes
If any cell of the Table is edited, the Save changes button appears at the footer of the Table. Save changes event is triggered when this button is clicked.
Page changed
If server-side pagination is enabled, this event is fired when the current page is changed. Page changed event is triggered after updating the pageIndex
variable.
Search
Search event is triggered when a text is entered to the search input box of the Table. searchText
variable is updated before triggering this event.
Cancel changes
If any cell of the Table is edited, the Discard changes
button appears at the footer of the Table. Cancel changes event is triggered when this button is clicked.
Sort applied
This event is triggered when the column name header is clicked to apply sorting in asc
or desc
. The sortApplied
variable is updated with an object having column
and direction
values.
Cell value changed
If any cell of the Table is edited, the cell value changed event is triggered.