ngx-datatable icon indicating copy to clipboard operation
ngx-datatable copied to clipboard

Columns Squish together under certain conditions

Open matthewbrozen opened this issue 7 years ago • 31 comments

I'm submitting a ... (check one with "x")

[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 a angular 4 application that uses angular material mat tabs to display multiple ngx-datatables. Sometimes when I go from tab to tab under certain conditions the tables columns get squished together but when I open the google developer tools to inspect it the table fixes itself

Expected behavior The expected behavior is that the columns display in their proper format and don't get squished together

Reproduction of the problem squished

This is a large project and I am not able to recreate the issue in plunker but I have attached the image of the bug. This occurs with angular material 2.0.0-beta.12 mat-tabs.

What is the motivation / use case for changing the behavior? To properly display the data

Please tell us about your environment:

OS X El Capitan version 10.11.6

Atom IDE

NPM 4.3.0

angular/cli 1.4.9

swimlane/ngx-datatable 9.3.1

Chrome

  • Table version: 0.8.x

swimlane/ngx-datatable 9.3.1

  • Angular version: 2.0.x

angular/core 4.2.4

  • Browser:

Chrome

  • Language:

Typescript

matthewbrozen avatar Nov 30 '17 00:11 matthewbrozen

I've seen this same thing when the screen changes sizes and there's a table that's still in the dom but out of view because of tabs or something. What happens if you remove the table and then put it back when the view switches back?

mcblum avatar Nov 30 '17 21:11 mcblum

I have a similar issue after upgrading from 11.0.4 to 11.1.5 However, for me the header columns are squished but the body is normal. This may be because I set the columns first, and then later set the data. The header columns layout correctly once I scroll the table.

arlowhite avatar Dec 07 '17 18:12 arlowhite

Inspect the <div> around <datatable-header-cell> with class="datatable-row-center" During the bug, it has width: 0px; After scrolling, the width gets a value.

arlowhite avatar Dec 07 '17 18:12 arlowhite

Another similar issue is that when I pin a column, it is "squished" until I scroll (vertically or horizontally).

arlowhite avatar Dec 07 '17 19:12 arlowhite

I had the same issue after upgrading to 11.1.5

padilla-jm avatar Dec 21 '17 20:12 padilla-jm

Same here, had to pin 11.0.4.

olaf89 avatar Dec 21 '17 21:12 olaf89

Does this have anything to do with #1161? We've been struggling with that.

mcblum avatar Dec 21 '17 21:12 mcblum

Just wanna push this, happens here too. BTW, using it inside of a Material Tab.

Logic-Bits avatar Jan 04 '18 14:01 Logic-Bits

Same here. Issue occurs since updating from 11.0.4 to 11.1.7. I'm not using the datatable inside a material tab. Column mode is set to fixed and width values are applied correctly to the style attribute.

Headers and columns are squished as shown in the original post's screenshot.

EDIT: "Sometimes" only the headers get squished. Data columns are fine. Also: When I start scrolling - everything squished is immediately resized correctly.

kuhlschrank avatar Jan 08 '18 16:01 kuhlschrank

Same here, only a windows resize corrects it (i'm in force column mode). In my case only headers are squished, data is ok.

However, I think I got to the bottom of this and made a PR which hopefully fixes the header issue.

For a quick fix and see if it works for you, go to file @swimlane/ngx-datatable/src/components/header/header.component.ts line 103. Basically at the end of the @Input() set columns() property and add the line this.setStylesByGroup(); at the end. Let me know if this works for you ?!

darkurse avatar Jan 17 '18 16:01 darkurse

I am having this issue too. I change the set of columns in my tables a lot, so having the recalculation of the column widths (including in the headers) work correctly is important to me.

jkon avatar Jan 23 '18 16:01 jkon

Well I found a temporary solution to this one. I receive the table data in the setTimeout giving it a minimal time of 100 ms. Now it stays squished for like 100ms and gets back to normal, you won't even realize that it was squished at any moment. I know this is not a perfect solution but glad I have something that is working fine and I didn't had to deal with version change.

kumaranish8888 avatar Apr 10 '18 14:04 kumaranish8888

This would happen to me on activate on a row or initial loading of a table. This only happened when I had two tables with the same columns object and one of the two tables was hidden making the browser report a width of zero on the column I suppose. I didn't dive into the code to see where this happened or why but hopefully this can help someone.

Made a stackblitz to illustrate the issue. Resize to have the first table "re-appear" and then do something to toggle a row's activate event and the tables will squish back to zero.

witheroux avatar Apr 25 '18 18:04 witheroux

+1 -- for me it's when users go from smaller window to max size. Resize just doesn't fire

PLopezD avatar May 30 '18 17:05 PLopezD

Same issue here

gpessa avatar Jun 11 '18 11:06 gpessa

+1

arturtupiassu avatar Jun 12 '18 20:06 arturtupiassu

Can confirm this is still a very real thing. If you have two tables tabs of that hide the table they contain. if you resize and jump back and forth there is some crazy behaviour going on. I'd be happy to put in a PR if an experienced dev could point me towards the table resizing logic.

la-jamesh avatar Jun 20 '18 21:06 la-jamesh

+1

V-Mario avatar Jul 18 '18 14:07 V-Mario

Same issue...

koderi-dp avatar Jul 27 '18 16:07 koderi-dp

+1

brandonyoung avatar Jul 27 '18 20:07 brandonyoung

+1

Any update on this? May have to switch to a different data table if this doesn't get figured out as it's killing or UI currently.

hensleyrob avatar Aug 24 '18 15:08 hensleyrob

+1 I might have the same issue. I am reusing a datatable component in a modal and when I have resized the browser window before (does not matter, if there was another datatable on it or not) then the contents of the table, when I open it, gets squished to the left. When I resize the window again, it jumps back to looking fine.

duck74 avatar Aug 30 '18 11:08 duck74

when we can expect this pull request #1561 in master?

koderi-dp avatar Oct 01 '18 10:10 koderi-dp

Hi, Just to bump up on this, am still experiencing it. is there a fix for this? Thanks

donnalmh avatar Jun 28 '19 01:06 donnalmh

I think you should switch to primeng...

koderi-dp avatar Jun 28 '19 10:06 koderi-dp

I just experienced this with a custom component rendering my <ngx-datatable> through content projection (by using <ng-content>)

If the datatable has it's inputs populated, but the parent component only renders it's body afterwards, this could occur.

Fixed by firing a window resize event, and writing the relevant unit test, but since this project isn't maintained much any more - if anyone has severe issues with this, might be worth investigating using a more supported datatable library, primeng or ag-grid to name some.

Unless... @marjan-georgiev - is there any chance of someone being assigned to this project to attend to/review the open PRs that may resolve the issues open & allow more open source contribution & interaction?

jarodsmk avatar Feb 10 '20 07:02 jarodsmk

On Init just invoke the resize event //javascript window.dispatchEvent(new Event('resize')) This works fine with me

azeay avatar Feb 28 '21 13:02 azeay

Trying everything I could think of, adding this CSS to my global styles seems to work so far:

datatable-body-cell.datatable-body-cell {
    width: -webkit-fill-available !important;
}

pgqueme avatar Sep 21 '22 19:09 pgqueme

+1

Arti3DPlayer avatar Mar 30 '23 16:03 Arti3DPlayer

Did anyone manage to solve this? 😂

jcandiap avatar Apr 27 '23 21:04 jcandiap