@@ -219,7 +219,9 @@ export class DatatableComponent<TRow extends Row = any>
219219 * The row height; which is necessary
220220 * to calculate the height for the lazy rendering.
221221 */
222- @Input ( ) rowHeight : number | 'auto' | ( ( row : TRow ) => number ) = 30 ;
222+ readonly rowHeight = input < number | 'auto' | ( ( row : TRow ) => number ) > (
223+ this . configuration ?. rowHeight ?? 30
224+ ) ;
223225
224226 /**
225227 * Type of column width distribution formula.
@@ -231,13 +233,15 @@ export class DatatableComponent<TRow extends Row = any>
231233 * The minimum header height in pixels.
232234 * Pass a falsey for no header
233235 */
234- @ Input ( ) headerHeight : number | 'auto' = 30 ;
236+ readonly headerHeight = input < number | 'auto' > ( this . configuration ?. headerHeight ?? 30 ) ;
235237
236238 /**
237239 * The minimum footer height in pixels.
238240 * Pass falsey for no footer
239241 */
240- @Input ( { transform : numberAttribute } ) footerHeight = 0 ;
242+ readonly footerHeight = input ( this . configuration ?. footerHeight ?? 0 , {
243+ transform : numberAttribute
244+ } ) ;
241245
242246 /**
243247 * If the table should use external paging
@@ -359,7 +363,9 @@ export class DatatableComponent<TRow extends Row = any>
359363 /**
360364 * Css class overrides
361365 */
362- @Input ( ) cssClasses : Partial < Required < NgxDatatableConfig > [ 'cssClasses' ] > = { } ;
366+ readonly cssClasses = input < Partial < Required < NgxDatatableConfig > [ 'cssClasses' ] > > (
367+ this . configuration ?. cssClasses ? { ...this . configuration . cssClasses } : { }
368+ ) ;
363369
364370 /**
365371 * Message overrides for localization
@@ -381,7 +387,9 @@ export class DatatableComponent<TRow extends Row = any>
381387 * }
382388 * ```
383389 */
384- @Input ( ) messages : Partial < Required < NgxDatatableConfig > [ 'messages' ] > = { } ;
390+ readonly messages = input < Partial < Required < NgxDatatableConfig > [ 'messages' ] > > (
391+ this . configuration ?. messages ? { ...this . configuration . messages } : { }
392+ ) ;
385393
386394 /**
387395 * A function which is called with the row and should return either:
@@ -541,7 +549,7 @@ export class DatatableComponent<TRow extends Row = any>
541549 */
542550 @HostBinding ( 'class.fixed-header' )
543551 get isFixedHeader ( ) : boolean {
544- const headerHeight : number | string = this . headerHeight ;
552+ const headerHeight : number | string = this . headerHeight ( ) ;
545553 return typeof headerHeight === 'string' ? ( headerHeight as string ) !== 'auto' : true ;
546554 }
547555
@@ -551,7 +559,7 @@ export class DatatableComponent<TRow extends Row = any>
551559 */
552560 @HostBinding ( 'class.fixed-row' )
553561 get isFixedRow ( ) : boolean {
554- return this . rowHeight !== 'auto' ;
562+ return this . rowHeight ( ) !== 'auto' ;
555563 }
556564
557565 /**
@@ -712,7 +720,7 @@ export class DatatableComponent<TRow extends Row = any>
712720 _columns ! : TableColumn [ ] ;
713721 _subscriptions : Subscription [ ] = [ ] ;
714722 _ghostLoadingIndicator = false ;
715- _defaultColumnWidth ?: number ;
723+ _defaultColumnWidth = this . configuration ?. defaultColumnWidth ?? 150 ;
716724 /**
717725 * To have this available for all components.
718726 * The Footer itself is not available in the injection context in templates,
@@ -726,22 +734,6 @@ export class DatatableComponent<TRow extends Row = any>
726734 // this will be set to true once rows are available and rendered on UI
727735 private readonly _rowInitDone = signal ( false ) ;
728736
729- constructor ( ) {
730- // apply global settings from Module.forRoot
731- if ( this . configuration ) {
732- if ( this . configuration . messages ) {
733- this . messages = { ...this . configuration . messages } ;
734- }
735- if ( this . configuration . cssClasses ) {
736- this . cssClasses = { ...this . configuration . cssClasses } ;
737- }
738- this . headerHeight = this . configuration . headerHeight ?? this . headerHeight ;
739- this . footerHeight = this . configuration . footerHeight ?? this . footerHeight ;
740- this . rowHeight = this . configuration . rowHeight ?? this . rowHeight ;
741- this . _defaultColumnWidth = this . configuration . defaultColumnWidth ?? 150 ;
742- }
743- }
744-
745737 /**
746738 * Lifecycle hook that is called after data-bound
747739 * properties of a directive are initialized.
@@ -984,8 +976,8 @@ export class DatatableComponent<TRow extends Row = any>
984976 if ( this . headerElement ) {
985977 height = height - this . headerElement . nativeElement . getBoundingClientRect ( ) . height ;
986978 }
987- if ( this . footerHeight ) {
988- height = height - this . footerHeight ;
979+ if ( this . footerHeight ( ) ) {
980+ height = height - this . footerHeight ( ) ;
989981 }
990982 this . bodyHeight = height ;
991983 }
@@ -1064,7 +1056,7 @@ export class DatatableComponent<TRow extends Row = any>
10641056 // This is because an expanded row is still considered to be a child of
10651057 // the original row. Hence calculation would use rowHeight only.
10661058 if ( this . scrollbarV ( ) && this . virtualization ( ) ) {
1067- const size = Math . ceil ( this . bodyHeight / ( this . rowHeight as number ) ) ;
1059+ const size = Math . ceil ( this . bodyHeight / ( this . rowHeight ( ) as number ) ) ;
10681060 return Math . max ( size , 0 ) ;
10691061 }
10701062
0 commit comments