You need to sign in to do that
Don't have an account?
Brian11
Lightning DataTable is not resizing when window resizes.
When I resize the browser window to a larger size the lightning Datatable expands to fill the extra space. Which is working correctly
When I resize the browser window to a smaller size the lightning Datatable does not adjusts to fit the new screen size. It remains at its larger size causing the recordpage to have a horizontal scroll.
Is there a fix around this? I am using the following component:
https://developer.salesforce.com/docs/component-library/bundle/lightning:datatable/example
Sorry for this issue you are encountering.
May I suggest you please check with below link with a similar discussion which might help you further.
- https://github.com/swimlane/ngx-datatable/issues/1090
Please let us know if this helps.Thanks,
Nagendra
Unfortunately the github issue example you sent did not seem to fix the problem. I believe its an issue that is still open. Any other information you have would be great.
In the controller's init, I do this:
// This catches the 'resize' event, which is whenever the browser window resizes.
window.addEventListener( 'resize', function(){
// Hide/Show the datatable to get it to resize
component.set( "v.renderDataTable","false" );
component.set( "v.renderDataTable","true" );
});
And then in the component, I do this:
<aura:attribute name="renderDataTable" type="Boolean" default="true"/>
.....
<aura:renderIf isTrue="{!v.renderDataTable}">
<lightning:datatable suppressBottomBar="true"
aura:id="table2"
columns="{! v.columns }"
data="{! v.opendata }"
keyField="Id"
selectedRows="{! v.selectedRows }"
onsort="{!c.updateSortingOpen}"
sortedBy="{!v.sortedByOpen}"
sortedDirection="{!v.sortedDirectionOpen}"
oncellchange="{! c.handleSaveEdition2 }"
onrowselection="{! c.updateSelected }"
onrowaction="{! c.handleRowAction2 }"
draftValues="{! v.draftValues }"
hideCheckboxColumn="true"/>
</aura:renderIf>
Seems to work.