@@ -367,6 +367,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
367
367
if ( ! this . _isDatasetInitialized && this . gridOptions . enableCheckboxSelector ) {
368
368
this . loadRowSelectionPresetWhenExists ( ) ;
369
369
}
370
+ this . loadPresetsWhenDatasetInitialized ( ) ;
370
371
this . _isDatasetInitialized = true ;
371
372
372
373
// also update the hierarchical dataset
@@ -487,49 +488,34 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
487
488
) ;
488
489
}
489
490
490
- // if user entered some Columns "presets", we need to reflect them all in the grid
491
- if ( gridOptions . presets && Array . isArray ( gridOptions . presets . columns ) && gridOptions . presets . columns . length > 0 ) {
492
- const gridColumns : Column [ ] = this . gridStateService . getAssociatedGridColumns ( grid , gridOptions . presets . columns ) ;
493
- if ( gridColumns && Array . isArray ( gridColumns ) && gridColumns . length > 0 ) {
494
- // make sure that the checkbox selector is also visible if it is enabled
495
- if ( gridOptions . enableCheckboxSelector ) {
496
- const checkboxColumn = ( Array . isArray ( this . _columnDefinitions ) && this . _columnDefinitions . length > 0 ) ? this . _columnDefinitions [ 0 ] : null ;
497
- if ( checkboxColumn && checkboxColumn . id === '_checkbox_selector' && gridColumns [ 0 ] . id !== '_checkbox_selector' ) {
498
- gridColumns . unshift ( checkboxColumn ) ;
499
- }
491
+ if ( ! this . customDataView ) {
492
+ // bind external sorting (backend) when available or default onSort (dataView)
493
+ if ( gridOptions . enableSorting ) {
494
+ // bind external sorting (backend) unless specified to use the local one
495
+ if ( gridOptions . backendServiceApi && ! gridOptions . backendServiceApi . useLocalSorting ) {
496
+ this . sortService . bindBackendOnSort ( grid ) ;
497
+ } else {
498
+ this . sortService . bindLocalOnSort ( grid ) ;
500
499
}
501
-
502
- // finally set the new presets columns (including checkbox selector if need be)
503
- grid . setColumns ( gridColumns ) ;
504
- }
505
- }
506
-
507
- // bind external sorting (backend) when available or default onSort (dataView)
508
- if ( gridOptions . enableSorting && ! this . customDataView ) {
509
- // bind external sorting (backend) unless specified to use the local one
510
- if ( gridOptions . backendServiceApi && ! gridOptions . backendServiceApi . useLocalSorting ) {
511
- this . sortService . bindBackendOnSort ( grid , dataView ) ;
512
- } else {
513
- this . sortService . bindLocalOnSort ( grid , dataView ) ;
514
500
}
515
- }
516
501
517
- // bind external filter (backend) when available or default onFilter (dataView)
518
- if ( gridOptions . enableFiltering && ! this . customDataView ) {
519
- this . filterService . init ( grid ) ;
502
+ // bind external filter (backend) when available or default onFilter (dataView)
503
+ if ( gridOptions . enableFiltering ) {
504
+ this . filterService . init ( grid ) ;
520
505
521
- // if user entered some Filter "presets", we need to reflect them all in the DOM
522
- if ( gridOptions . presets && Array . isArray ( gridOptions . presets . filters ) && gridOptions . presets . filters . length > 0 ) {
523
- this . filterService . populateColumnFilterSearchTermPresets ( gridOptions . presets . filters ) ;
524
- }
525
- // bind external filter (backend) unless specified to use the local one
526
- if ( gridOptions . backendServiceApi && ! gridOptions . backendServiceApi . useLocalFiltering ) {
527
- this . filterService . bindBackendOnFilter ( grid , dataView ) ;
528
- } else {
529
- this . filterService . bindLocalOnFilter ( grid , dataView ) ;
506
+ // bind external filter (backend) unless specified to use the local one
507
+ if ( gridOptions . backendServiceApi && ! gridOptions . backendServiceApi . useLocalFiltering ) {
508
+ this . filterService . bindBackendOnFilter ( grid ) ;
509
+ } else {
510
+ this . filterService . bindLocalOnFilter ( grid ) ;
511
+ }
530
512
}
513
+
514
+ // load any presets if any (after dataset is initialized)
515
+ this . loadPresetsWhenDatasetInitialized ( ) ;
531
516
}
532
517
518
+
533
519
// if user set an onInit Backend, we'll run it right away (and if so, we also need to run preProcess, internalPostProcess & postProcess)
534
520
if ( gridOptions . backendServiceApi ) {
535
521
const backendApi = gridOptions . backendServiceApi ;
@@ -812,6 +798,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
812
798
if ( ! this . _isDatasetInitialized && ( this . gridOptions . enableCheckboxSelector || this . gridOptions . enableRowSelection ) ) {
813
799
this . loadRowSelectionPresetWhenExists ( ) ;
814
800
}
801
+ this . loadPresetsWhenDatasetInitialized ( ) ;
815
802
this . _isDatasetInitialized = true ;
816
803
}
817
804
}
@@ -917,6 +904,32 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
917
904
}
918
905
}
919
906
907
+ private loadPresetsWhenDatasetInitialized ( ) {
908
+ if ( this . gridOptions && ! this . customDataView ) {
909
+ // if user entered some Filter "presets", we need to reflect them all in the DOM
910
+ if ( this . gridOptions . presets && Array . isArray ( this . gridOptions . presets . filters ) && this . gridOptions . presets . filters . length > 0 ) {
911
+ this . filterService . populateColumnFilterSearchTermPresets ( this . gridOptions . presets . filters ) ;
912
+ }
913
+
914
+ // if user entered some Columns "presets", we need to reflect them all in the grid
915
+ if ( this . gridOptions . presets && Array . isArray ( this . gridOptions . presets . columns ) && this . gridOptions . presets . columns . length > 0 ) {
916
+ const gridColumns : Column [ ] = this . gridStateService . getAssociatedGridColumns ( this . grid , this . gridOptions . presets . columns ) ;
917
+ if ( gridColumns && Array . isArray ( gridColumns ) && gridColumns . length > 0 ) {
918
+ // make sure that the checkbox selector is also visible if it is enabled
919
+ if ( this . gridOptions . enableCheckboxSelector ) {
920
+ const checkboxColumn = ( Array . isArray ( this . _columnDefinitions ) && this . _columnDefinitions . length > 0 ) ? this . _columnDefinitions [ 0 ] : null ;
921
+ if ( checkboxColumn && checkboxColumn . id === '_checkbox_selector' && gridColumns [ 0 ] . id !== '_checkbox_selector' ) {
922
+ gridColumns . unshift ( checkboxColumn ) ;
923
+ }
924
+ }
925
+
926
+ // finally set the new presets columns (including checkbox selector if need be)
927
+ this . grid . setColumns ( gridColumns ) ;
928
+ }
929
+ }
930
+ }
931
+ }
932
+
920
933
/**
921
934
* local grid, check if we need to show the Pagination
922
935
* if so then also check if there's any presets and finally initialize the PaginationService
@@ -1016,7 +1029,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy, OnIn
1016
1029
}
1017
1030
1018
1031
// we will display the custom footer only when there's no Pagination
1019
- if ( ! this . gridOptions . enablePagination ) {
1032
+ if ( ! this . gridOptions . enablePagination && ! this . _isPaginationInitialized ) {
1020
1033
this . showCustomFooter = this . gridOptions . hasOwnProperty ( 'showCustomFooter' ) ? this . gridOptions . showCustomFooter : false ;
1021
1034
this . customFooterOptions = this . gridOptions . customFooterOptions || { } ;
1022
1035
}
0 commit comments