Lightning datatable header scrolls along with values in my LWC. How can I make the headers fixed? I tried pasting the datatable code from here and adding CSS position:fixed
attribute, but it did not work as expected.
HTML:
<div>
<lightning-datatable key-field="Id" data={wrappers} columns={columns}
onrowaction={navigateToRecordViewPage} hide-checkbox-column="true">
</lightning-datatable>
</div>
Javascript:
const columns = [
{
label: 'View',
type: 'button',
initialWidth: 50,
typeAttributes: {
label: 'View',
title: 'View',
variant: 'base',
alternativeText: 'View',
target:'_blank'
}
},
{ label: 'Name', fieldName: 'name', type:'text' },
{ label: 'Email', fieldName: 'email', type: 'email' },
{ label: 'Phone', fieldName: 'phone', type: 'phone'},
{ label: 'MDM ID', fieldName: 'mdm', type: 'text' },
];