question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Browser resize distorts ngx-datatable when used with material tabs

See original GitHub issue
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, post on Stackoverflow or Gitter

Current behavior I have added multiple grids in material tabs. Initially it load correctly but after resizing, page gets distorted. grid1 grid2

Expected behavior Data table should render properly on browser resize.

Reproduction of the problem I have created below stackblitz open this and resize the browser back and forth and see the tabs again. https://angular-ngx-datatable-resize-issue.stackblitz.io/

https://stackblitz.com/edit/angular-ngx-datatable-resize-issue

What is the motivation / use case for changing the behavior? Better user interface

Please tell us about your environment: Operating: system: Windows 7 package manager: npm

  • Table version: 0.8.x 11.2.0

  • Angular version: 2.0.x 5.2.x

  • 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 ] Chrome

  • Language: [all | TypeScript X.X | ES6/7 | ES5] Typescript.

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:8
  • Comments:14

github_iconTop GitHub Comments

8reactions
sakib0hasancommented, Mar 11, 2019

Hi guys, with help of @Moulde’s idea, I believe I have a hacky solution! First, you need to listen for the selectedTabChange event. Like this:

<mat-tab-group (selectedTabChange)="onTabChange($event)">

Then, on the onTabChange function, you need to fire the Window Resize event forcefully.

onTabChange(event: MatTabChangeEvent) {
        window.dispatchEvent(new Event('resize'));
}

And voilà! Its working fine for me!

7reactions
arturtupiassucommented, Jun 12, 2018

I have a very similar issue, with a ngx-datatable inside a bootstrap tab. The columns get all condensed/shrinked at the beginning of the table. If I simply resize de browser window, the table show correctly again. Problem Doesn’t happen outside of tabs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Browser resize distorts ngx-datatable when used with material tabs
I have added multiple grids in material tabs. Initially it load correctly but after resizing, page gets distorted. ... Data table should render...
Read more >
html - angular how to resize ngx-datatable while closing and ...
In my use case, I needed to do the refresh after some amount of time along with ChangeDetectorRef to make it work.
Read more >
Ngx-Datatable - Rows Are Not Rendered Properly In Tab Set
I have added multiple grids in material tabs. Initially it load correctly but after resizing page gets distorted. Data table should render. Swimlane ......
Read more >
Table row colors getting distorted on resize/click events
$(window).on('scroll resize', function(){ var table = $('#our-table').DataTable(); table.columns.adjust().draw(); });. We are using ...
Read more >
Angular Ngx Datatable Resize Issue (forked) - StackBlitz
Editor Preview Both. Sign in. Project. Search. Settings. Switch to Light Theme. Enter Zen Mode. Project. Download Project. Info. Angular Ngx Datatable ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found