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

headerHeight=auto throwing build time error. Working fine while development. #2048

Open shabbirdhangot opened 2 years ago

shabbirdhangot commented 2 years ago

I'm submitting a ...

[ 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

Setting headerHeight auto working in the dev environment (ng serve) but throwing error while production build (ng build --prod)

 Type 'string' is not assignable to type 'number'.  

 <ngx-datatable class="material" columnMode="force" headerHeight="auto" [footerHeight]="0" rowHeight="auto"

Expected behavior

It should work in both environment.

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

I have long header for my table. In that case headerHeight auto is best option for me.

Please tell us about your environment:

-all

BEagle1984 commented 2 years ago

The headerHeight property is declared as number only.

https://github.com/swimlane/ngx-datatable/blob/d71246ad6cc3d61a87049712c761ceb3ee07b3c8/projects/swimlane/ngx-datatable/src/lib/components/datatable.component.ts#L192

But later in the code it is compared against the "auto" string and that's therefore a valid value.

https://github.com/swimlane/ngx-datatable/blob/d71246ad6cc3d61a87049712c761ceb3ee07b3c8/projects/swimlane/ngx-datatable/src/lib/components/datatable.component.ts#L465-L468

It should be declared like the rowHeight property, so:"

  @Input() headerHeight: number | 'auto' | ((row?: any) => number) = 30;

Dropping a PR...