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.

body height is too small (recalculate dimensions not working correctly)

See original GitHub issue

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

Current behavior When loading NGX-Datablewith virtual scrolling enabled, the body height is calculated incorrectly.

the height of the table element (this.element) is set to 118px, should I be setting this manually?

the body of the datatable is set to a height of 19px but the row height is set to 50.

the ng-reflect-body-height is set to “19”, not sure why this is getting calculated incorrectly.

Expected behavior More than 1 row should be appearing and the body height should be number of rows multiplied by the row height (at a minimum).

Reproduction of the problem

The code:

<ngx-datatable
   class="material"
   [rows]="rows"
   [columns]="columns"
   [loadingIndicator]="loading"
   [scrollbarV]="true"
   [rowHeight]="50"
   [headerHeight]="50"
   [footerHeight]="50"
   ></ngx-datatable>

too-small-table

the issue seems to be here: https://github.com/swimlane/ngx-datatable/blob/c3a1ba2e542416ba45fe1b4040db7abebac9ce7b/src/components/datatable.component.ts#L764

What is the motivation / use case for changing the behavior? It doesn’t look good and there’s no way to monkeypatch this so the height is calculated correctly.

Please tell us about your environment:

Ubuntu 16.04 LTS

  • Table version: 6.0.1

  • Angular version: 2.3.0

  • Browser: Chrome | Firefox

  • Language: TypeScript 2.1.5 (compiling to ES6)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:7
  • Comments:19 (3 by maintainers)

github_iconTop GitHub Comments

12reactions
rajeshvayacommented, Mar 28, 2017

If we set height of the ngx-datatable like the below example it works - The height has to calculated with header and footer height in mind

E.g.

<ngx-datatable style="height: 439px;"
            class="material"
            [rows]="rows"
            [columnMode]="'standard'"
            [headerHeight]="40"
            [footerHeight]="50"
            [rowHeight]="35"
            [scrollbarV]="true">

The height 439px was calculated to display 10 rows per page as follows: Header height + Footer height + (Number of rows to display on one page * row height)

Due to the css and font size of your app the header and footer height may increase - inspect the header and footer element through dev tools to get the accurate height.

439px = 38 + 51 + (35 * 10)

7reactions
professorjoshuacommented, Mar 27, 2017

Can we create a property for how many rows we can display when using a vertical scroll?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make body have 100% of the browser height - Stack Overflow
I think body min-height and its child height problem is because you can not calculate the % value of dynamic property as min-height....
Read more >
HTML vs Body: How to Set Width and Height for Full Page Size
This problem arises when any element - not just the HTML or body element - is set to 100vw (viewport width) units. The...
Read more >
Background image height problem - not fitting to the screen
Your body hasn't the full height of the screen. And the background size you now use (100%, 100%) looks therefore out of scale....
Read more >
Setting Height And Width On Images Is Important Again
Yes, when an image is being shown at full size, without any CSS changing any dimensions, it is useful to resolve the layout...
Read more >
object-fit - CSS: Cascading Style Sheets - MDN Web Docs
The object-fit CSS property sets how the content of a replaced element, such as an or , should be resized to fit its...
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