ngx-datatable: Datatable width resize problem. datatable-scroller and datatable-header-inner does not resize after initial load
I’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
Current behavior datatable-scroller and datatable-header-inner(also it’s children) doesn’t resize on width after datatable inital load
Expected behavior They should resize… https://cl.ly/1U090c3Q0X2S
Reproduction of the problem You can represent the problem anywhere.
What is the motivation / use case for changing the behavior? This is a bug.
Please tell us about your environment: macOS Sierra, Chrome Version 60.0.3112.101
-
Table version: 9.3.0, 10.0.5
-
Angular version: 4.3.3
-
Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]
-
Language: [all | TypeScript X.X | ES6/7 | ES5]
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 22
- Comments: 26
Adding a simple css rule for
.datatable-scrolldisplay: inherit !important;works for me@webmatrixxxl Hi i have simple solution for this. You just need to trigger window resize event.
window.dispatchEvent(new Event('resize'));I have also encountered this. Some things I’ve tried is to trigger recalculate table but that does not fix the problem.
Well
It seems that the scroller width is calculated in the body.component.ts file
Now this.columnGroupWidths dictates the width of the scroller and this is sadly not recalculated on ngxDatatable.recalculate(); function.
What I did is every time I want to recalculate I firstly reset the columns pointer in the datatable and then recalculate. Seemed to fix the issue for me!
component.ts
component.html
Same here. After ngShow/ngIf the table didn’t recalculate columns width until viewport resize event is manually triggered.
ngAfterViewChecked():void{ window.dispatchEvent(new Event(‘resize’)); }
it works!
Is this still an open issue for everyone? I am running into a similar issue with the latest release and was wondering what the recommended workaround is or if anyone has a fork that fixes up the issue. (cc @marjan-georgiev in case there is a fix already in place from another issue)
These classes worked for me without adding any hooks or resize method.
.datatable-header-inner{ width: 100% !important; }
.datatable-scroll{ display: inherit !important; }
.datatable-row-center{ width: 100% !important; }
.datatable-body-row{ width: 100% !important; }
this one work with me many thanks
I have made so many try but this things works for me. Thank you.
Here’s a hack I implemented in the component containing the datatable: