You need to sign in to do that
Don't have an account?
Natalya Murphy 8
Right-align column headings in lightning:datatable
I'm using a lightning:datatable to retreive data and want the date-formatted columns to be right-aligned. I've figured out how to right-align the actual data, but the column heading is still left-aligned and I can't find any documentation on how to right-align it.
datatable definition:
...and a snippet of the column definition setting the right-align of the data:
Also attaching a picture showing the problem.
datatable definition:
<lightning:datatable keyField="id" data="{! v.eeObject.serviceBranches }" columns="{! v.serviceColumns }" hideCheckboxColumn="true"/>
...and a snippet of the column definition setting the right-align of the data:
component.set('v.serviceColumns', [ {label: 'Entry Date', fieldName: 'serviceEntryDate', type: 'date-local', typeAttributes:{ month: "numeric", day: "numeric" }, cellAttributes: { alignment: 'right' }}, {label: 'Exit Date', fieldName: 'serviceExitDate', type: 'date-local', typeAttributes:{ month: "numeric", day: "numeric" }, cellAttributes: { alignment: 'left' }} ]);
Also attaching a picture showing the problem.
Greetings to you!
Unfortunately, there is no standard way to align table headers to right. As a workaround, you can use CSS but it might break in upcoming releases. Please refer to the below link which might help you further with the above requirement.
https://salesforce.stackexchange.com/questions/215870/lightningdatatable-with-right-to-left-does-not-display-good
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas