@@ -306,6 +306,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy {
306306 this . groupingService = externalServices ?. groupingAndColspanService ?? new GroupingAndColspanService ( this . extensionUtility , this . _eventPubSubService ) ;
307307
308308 this . serviceList = [
309+ this . containerService ,
309310 this . extensionService ,
310311 this . filterService ,
311312 this . gridEventService ,
@@ -423,6 +424,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy {
423424 this . datasetHierarchical = undefined ;
424425 this . _columnDefinitions = [ ] ;
425426 this . _angularGridInstances = undefined ;
427+ this . slickGrid = undefined as any ;
426428 }
427429
428430 emptyGridContainerElm ( ) {
@@ -556,8 +558,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy {
556558
557559 // if you don't want the items that are not visible (due to being filtered out or being on a different page)
558560 // to stay selected, pass 'false' to the second arg
559- const selectionModel = this . slickGrid ?. getSelectionModel ( ) ;
560- if ( selectionModel && this . gridOptions && this . gridOptions . dataView && this . gridOptions . dataView . hasOwnProperty ( 'syncGridSelection' ) ) {
561+ if ( this . slickGrid ?. getSelectionModel ( ) && this . gridOptions && this . gridOptions . dataView && this . gridOptions . dataView . hasOwnProperty ( 'syncGridSelection' ) ) {
561562 // if we are using a Backend Service, we will do an extra flag check, the reason is because it might have some unintended behaviors
562563 // with the BackendServiceApi because technically the data in the page changes the DataView on every page change.
563564 let preservedRowSelectionWithBackend = false ;
@@ -884,29 +885,28 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy {
884885 // When data changes in the DataView, we need to refresh the metrics and/or display a warning if the dataset is empty
885886 this . _eventHandler . subscribe ( dataView . onRowCountChanged , ( ) => {
886887 grid . invalidate ( ) ;
887- this . handleOnItemCountChanged ( this . dataView . getFilteredItemCount ( ) || 0 , dataView . getItemCount ( ) ) ;
888+ this . handleOnItemCountChanged ( dataView . getFilteredItemCount ( ) || 0 , dataView . getItemCount ( ) || 0 ) ;
888889 } ) ;
889890 this . _eventHandler . subscribe ( dataView . onSetItemsCalled , ( _e , args ) => {
890- grid . invalidate ( ) ;
891- this . handleOnItemCountChanged ( this . dataView . getFilteredItemCount ( ) , args . itemCount ) ;
891+ this . handleOnItemCountChanged ( dataView . getFilteredItemCount ( ) || 0 , args . itemCount ) ;
892892
893893 // when user has resize by content enabled, we'll force a full width calculation since we change our entire dataset
894894 if ( args . itemCount > 0 && ( this . gridOptions . autosizeColumnsByCellContentOnFirstLoad || this . gridOptions . enableAutoResizeColumnsByCellContent ) ) {
895895 this . resizerService . resizeColumnsByCellContent ( ! this . gridOptions ?. resizeByContentOnlyOnFirstLoad ) ;
896896 }
897897 } ) ;
898898
899- this . _eventHandler . subscribe ( dataView . onRowsChanged , ( _e , args ) => {
900- // filtering data with local dataset will not always show correctly unless we call this updateRow/render
901- // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
902- // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
903- if ( gridOptions ?. enableFiltering && ! gridOptions . enableRowDetailView ) {
899+ if ( gridOptions ?. enableFiltering && ! gridOptions . enableRowDetailView ) {
900+ this . _eventHandler . subscribe ( dataView . onRowsChanged , ( _e , args ) => {
901+ // filtering data with local dataset will not always show correctly unless we call this updateRow/render
902+ // also don't use "invalidateRows" since it destroys the entire row and as bad user experience when updating a row
903+ // see commit: https://github.com/ghiscoding/aurelia-slickgrid/commit/8c503a4d45fba11cbd8d8cc467fae8d177cc4f60
904904 if ( args ?. rows && Array . isArray ( args . rows ) ) {
905905 args . rows . forEach ( ( row : number ) => grid . updateRow ( row ) ) ;
906906 grid . render ( ) ;
907907 }
908- }
909- } ) ;
908+ } ) ;
909+ }
910910 }
911911 }
912912
@@ -1150,9 +1150,8 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy {
11501150 private loadRowSelectionPresetWhenExists ( ) {
11511151 // if user entered some Row Selections "presets"
11521152 const presets = this . gridOptions ?. presets ;
1153- const selectionModel = this . slickGrid ?. getSelectionModel ( ) ;
11541153 const enableRowSelection = this . gridOptions && ( this . gridOptions . enableCheckboxSelector || this . gridOptions . enableRowSelection ) ;
1155- if ( enableRowSelection && selectionModel && presets && presets . rowSelection && ( Array . isArray ( presets . rowSelection . gridRowIndexes ) || Array . isArray ( presets . rowSelection . dataContextIds ) ) ) {
1154+ if ( enableRowSelection && this . slickGrid ?. getSelectionModel ( ) && presets ? .rowSelection && ( Array . isArray ( presets . rowSelection . gridRowIndexes ) || Array . isArray ( presets . rowSelection . dataContextIds ) ) ) {
11561155 let dataContextIds = presets . rowSelection . dataContextIds ;
11571156 let gridRowIndexes = presets . rowSelection . gridRowIndexes ;
11581157
@@ -1262,7 +1261,7 @@ export class AngularSlickgridComponent implements AfterViewInit, OnDestroy {
12621261 // register all services by executing their init method and providing them with the Grid object
12631262 if ( Array . isArray ( this . _registeredResources ) ) {
12641263 for ( const resource of this . _registeredResources ) {
1265- if ( typeof resource . init === 'function' ) {
1264+ if ( this . slickGrid && typeof resource . init === 'function' ) {
12661265 resource . init ( this . slickGrid , this . containerService ) ;
12671266 }
12681267 }
0 commit comments