ngx-aur-mat-table 12.2.3 → 12.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -959,6 +959,7 @@
959
959
  this.indexProvider = new IndexProviderDummy();
960
960
  this.paginationProvider = new PaginationProviderDummy();
961
961
  this.totalRowProvider = new TotalRowProviderDummy();
962
+ this.customSortFunctions = new Map();
962
963
  }
963
964
  NgxAurMatTableComponent.prototype.ngOnChanges = function (changes) {
964
965
  if (changes['tableData'] && this.tableData) {
@@ -995,11 +996,19 @@
995
996
  NgxAurMatTableComponent.prototype.ngAfterViewInit = function () {
996
997
  var _this = this;
997
998
  this.tableDataSource.paginator = this.matPaginator;
998
- this.tableDataSource.sort = this.matSort;
999
+ this.initSortingDataAccessor();
999
1000
  this.updateColumnOffsets();
1000
1001
  this.resizeColumnOffsetsObserver = new ResizeObserver(function () { return _this.updateColumnOffsets(); });
1001
1002
  this.resizeColumnOffsetsObserver.observe(this.table.nativeElement);
1002
1003
  };
1004
+ NgxAurMatTableComponent.prototype.initSortingDataAccessor = function () {
1005
+ var _this = this;
1006
+ this.tableDataSource.sort = this.matSort;
1007
+ this.tableDataSource.sortingDataAccessor = function (data, key) {
1008
+ var customSortFunction = _this.customSortFunctions.get(key);
1009
+ return customSortFunction ? customSortFunction(data, key) : data[key];
1010
+ };
1011
+ };
1003
1012
  NgxAurMatTableComponent.prototype.updateColumnOffsets = function () {
1004
1013
  var offsets = Array.from(this.table.nativeElement.querySelectorAll('th'))
1005
1014
  .map(function (c) { return c; })
@@ -1008,6 +1017,7 @@
1008
1017
  };
1009
1018
  NgxAurMatTableComponent.prototype.prepareTableData = function () {
1010
1019
  this.initTable();
1020
+ this.initCustomSortFunctionsMap();
1011
1021
  this.indexProvider = IndexProvider.create(this.tableConfig)
1012
1022
  .addIndexColumn(this.displayedColumns);
1013
1023
  this.rowActionsProvider = RowActionProvider.create(this.tableConfig)
@@ -1021,6 +1031,12 @@
1021
1031
  .setStyle()
1022
1032
  .setTotalRow();
1023
1033
  };
1034
+ NgxAurMatTableComponent.prototype.initCustomSortFunctionsMap = function () {
1035
+ var _this = this;
1036
+ this.tableConfig.columnsCfg
1037
+ .filter(function (c) { return c.sort && c.sort.enable && c.sort.customSort; })
1038
+ .forEach(function (c) { return _this.customSortFunctions.set(c.key, c.sort.customSort); });
1039
+ };
1024
1040
  NgxAurMatTableComponent.prototype.initTable = function () {
1025
1041
  this.tableDataSource = MatTableDataSourceFactory.convert(this.tableData, this.tableConfig.columnsCfg);
1026
1042
  this.tableView = TableViewFactory.toView(this.tableDataSource.data, this.tableConfig);