-
Notifications
You must be signed in to change notification settings - Fork 93
soqlDatatable
Note: Please read the Configuration and Limitations pages as there are quite a few things to be aware of when using this component.
Also,
recipes
have plenty of correctly configured examples so you can learn the ins and outs of this LWC.
Create a fully featured lightning-datatable
with just a SOQL String.
This component can be used on a Flexipage as a list view or a related list. This can even be used inside Screen Flows.
Since this is built on top of the lightning-datatable
base component, all the bells and whistles can be inherited.
The below example showcases how easy it is to create a soqlDatatable
right in the Lightning App Builder with the following query string:
SELECT Name, Email, Phone, LeadSource, Level__c, AccountId, Account.Type FROM Contact LIMIT 50
name | type | access | required | default | description |
---|---|---|---|---|---|
recordId | String | public | no | ||
objectApiName | String | public | no | ||
isRecordBind | Boolean | public | true | Only on Record Page. Use $CurrentRecord or $recordId in your SOQL query to use record context. User must have FLS access. | |
title | String | public | no | ||
showRecordCount | Boolean | public | false | ||
showRefreshButton | Boolean | public | false | ||
queryString | String | public | yes | Order of fields in the SOQL string determine order of columns. Parent (one level) relationships supported (e.g. Account.Type) | |
checkboxType | String | public | no | None | None, Multi, or Single (outputs radios). This allows the component to emit the rowselection event.For Screen Flows this populates the selectedRows and firstSelectedRow output variables. |
editableFields | String[] | public | no | Comma separated list of Field API names for inline editing. Does not support parent relationship (Account.Type). Saving writes to server. | |
columnLabels | String[] | public | no | Comma separated list of Field API names mapped to a custom label using Apex Map kvp syntax: fieldApiName=>new custom label . |
|
sortableFields | String[] | public | no | Comma separated list of Field API names. Parent relationship is supported (e.g. Account.Type). | |
sortedBy | String | public | no | Single Field API Name. Parent relationship is supported (e.g. Account.Type). | |
sortedDirection | String | public | no | asc | |
actionConfigDevName | String | public | no | Not available on Flow Screen. Configure table and row actions with a record in Datatable_Config__mdt . |
|
lookupConfigDevName | String | public | no | Not available on Flow Screen. Configure inline edit lookup search behavior with a record in Datatable_Config__mdt . |
|
useLoadStyleHackForOverflow | Boolean | public | false | Enable this when your datatable has a small number of rows but you need in-line edit. This will override any custom table heights and allow for picklist and lookup edit menus to display on top of the datatable. However, you may experience some weird CSS issues. | |
useRelativeMaxHeight | Boolean | public | false | Force table height to 60% of the vertical screen space. Set to true and override with customRelativeMaxHeight when appropriate |
|
customHeight | String | public | no | Flow Screen only: String value (in px) for custom height of table | |
customRelativeMaxHeight | String | public | Use in conjunction with useRelativeMaxHeight to specify a custom percentage (relative to screen size) height for the component. |
||
selectedRows | SObject[] | public | Uses FlowAttributeChangeEvent to notify changes to Flow Screens. |
||
firstSelectedRow | SObject | public | Uses FlowAttributeChangeEvent to notify changes to Flow Screens. |
||
uniqueBoundary | String | public | Getter only: Use to retrieve the currently used boundary if you want to create your own abstraction on top of this component |
name | arguments | description |
---|---|---|
refreshTable | Refreshes the table (imperatively). | |
refreshTableWithQueryString | queryString | Refreshes the table (imperatively) but pass in a queryString to rerun validateQueryStringAndInitialize . |
resetTable | Clears attributes so component is fully reset. | |
suppressSpinner | Stops spinner from automatically spinning. You will need to implement your own spinners by listening to the events emitted |
All these events are bubbles
and composed
.
columnsload
The event fired when columns are loaded, providing the following parameter(s):
parameter | type | description |
---|---|---|
tableColumns | Array | The tableColumns (after post-processing) |
rowsLoad
The event fired when rows are loaded but not fully rendered, providing the following parameter(s):
parameter | type | description |
---|---|---|
tableData | Array |
rowselection
The event fired when single/multi checkboxes are enabled and row has been selected, providing the following parameter(s):
parameter | type | description |
---|---|---|
selectedRows | Array | The accumulated list of selected rows |
cellchange
The event fired when any custom data type cell has its draft value changed, providing the following parameter(s):
parameter | type | description |
---|---|---|
draftValues | Array | Contains row and column data from the changed cell |
editablecellrendered
The event fired when any custom data type cell finishes rendering (once, per cell).
It is recommended you debounce this with a couple hundred ms to listen to when the cells are fully done rendering.
This event does not provide any parameters.
Use the composedActions
slot to add additional actions to the left of the dynamically generated ones by Datatable_Config__mdt
.