Skip to content
This repository was archived by the owner on Jun 1, 2025. It is now read-only.

Commit 4e26ee0

Browse files
Ghislain BeaulacGhislain Beaulac
authored andcommitted
refactor(extension): cleanup and simplified some pieces of code
1 parent 8f661d4 commit 4e26ee0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/app/modules/angular-slickgrid/extensions/headerMenuExtension.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,19 +301,19 @@ export class HeaderMenuExtension implements Extension {
301301

302302
/** Clear the Sort on the current column (if it's actually sorted) */
303303
private clearColumnSort(e: Event, args: HeaderMenuOnCommandArgs) {
304-
if (args && args.column) {
304+
if (args && args.column && this.sharedService) {
305305
// get previously sorted columns
306306
const allSortedCols: ColumnSort[] = this.sortService.getPreviousColumnSorts();
307307
const sortedColsWithoutCurrent: ColumnSort[] = this.sortService.getPreviousColumnSorts(args.column.id + '');
308308

309309
if (allSortedCols.length !== sortedColsWithoutCurrent.length) {
310-
if (this.sharedService.gridOptions.backendServiceApi) {
310+
if (this.sharedService.gridOptions && this.sharedService.gridOptions.backendServiceApi) {
311311
this.sortService.onBackendSortChanged(e, { multiColumnSort: true, sortCols: sortedColsWithoutCurrent, grid: this.sharedService.grid });
312312
} else if (this.sharedService.dataView) {
313313
this.sortService.onLocalSortChanged(this.sharedService.grid, this.sharedService.dataView, sortedColsWithoutCurrent, true);
314314
} else {
315315
// when using customDataView, we will simply send it as a onSort event with notify
316-
const isMultiSort = this.sharedService && this.sharedService.gridOptions && this.sharedService.gridOptions.multiColumnSort || false;
316+
const isMultiSort = this.sharedService.gridOptions && this.sharedService.gridOptions.multiColumnSort || false;
317317
const sortOutput = isMultiSort ? sortedColsWithoutCurrent : sortedColsWithoutCurrent[0];
318318
args.grid.onSort.notify(sortOutput);
319319
}

0 commit comments

Comments
 (0)