swimlane / ngx-datatable

✨ A feature-rich yet lightweight data-table crafted for Angular
http://swimlane.github.io/ngx-datatable/
MIT License
4.63k stars 1.68k forks source link

exported ts types for row-details rowHeight doesn't allow 'auto' as a type #1958

Open Joeb3219 opened 3 years ago

Joeb3219 commented 3 years ago

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

The exported typings for the row-detail rowHeight property are number | (...) => number, whereas it has been shown in this issue that 'auto' or '100%' will actually work correctly. I have confirmed this locally -- I can use 'auto' as an option and everything works well.

You can use [rowHeight]="'auto'" in non-strict TS mode on templates, but not when strict template checking is enabled, as 'auto' isn't a number.

Expected behavior

The typings should reflect that 'auto' is a valid value. I can make this change, but wanted to open a bug report first, as it didn't seem crystal clear that this was meant to be supported.

Reproduction of the problem

What is the motivation / use case for changing the behavior?

Please tell us about your environment: Valid type checking, yielding no errors.

Ubuntu

joeveiga commented 3 years ago

@Joeb3219 as mentioned by @amcdnl in the issue you're referencing, the size is needed for virtual scroll functionality. This is a general problem not specific to ngx-datatable, see https://material.angular.io/cdk/scrolling/overview for example. If you want to open a feature request to discuss alternatives (maybe an option to disable virtual scrolling or something?) .

elinake commented 2 years ago

The way I managed to hack this with strict TS, is

<ngx-datatable-row-detail [rowHeight]="getHeight">

and

  public getHeight(): any {
    return '100%';
  }

Angular HTML templates don't allow ignoring TS rules so it's not possible to build with 'auto' there, but with 'any' you can usually ignore the rules in ts files.