@universis/ngx-tables 0.8.2 → 0.8.3

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.
@@ -1781,8 +1781,9 @@ var AdvancedTableComponent = /** @class */ (function () {
1781
1781
  if (_this.dataTable) {
1782
1782
  var info = _this.dataTable.page.info();
1783
1783
  _this.page.emit(info);
1784
- if (drawIndex_1 > 1)
1784
+ if (drawIndex_1 > 1) {
1785
1785
  return;
1786
+ }
1786
1787
  try {
1787
1788
  drawIndex_1++;
1788
1789
  setTimeout(function () { _this.dataTable.columns.adjust(); }, 1);
@@ -2361,7 +2362,7 @@ var AdvancedTableComponent = /** @class */ (function () {
2361
2362
  var index = columnOrder.indexOf(i);
2362
2363
  var visible = _this.dataTable.column(index).visible();
2363
2364
  // set title for select column
2364
- if (i == 0 && _this.selectable) {
2365
+ if (i === 0 && _this.selectable) {
2365
2366
  title = '<' + _this._translateService.instant('Tables.SelectColumn') + '>';
2366
2367
  }
2367
2368
  // get column title
@@ -2395,9 +2396,18 @@ var AdvancedTableComponent = /** @class */ (function () {
2395
2396
  });
2396
2397
  this._columnSelector.selectColumns(columns).then(function (event) {
2397
2398
  if (event.result === 'ok') {
2399
+ var sorted = event.columns
2400
+ .map(function (col) {
2401
+ return {
2402
+ key: col.key,
2403
+ index: col.index
2404
+ };
2405
+ })
2406
+ .sort(function (a, b) { return a.index - b.index; });
2398
2407
  // get column order e.g. [3, 1, 2, 0, 4]
2399
- var indexes = event.columns.map(function (item) {
2400
- return item.index;
2408
+ var indexes = sorted
2409
+ .map(function (item) {
2410
+ return event.columns.findIndex(function (next) { return item.key === next.key; });
2401
2411
  });
2402
2412
  // reset column visibilty
2403
2413
  for (var index = 0; index < event.columns.length; index++) {
@@ -2511,12 +2521,10 @@ var AdvancedTableComponent = /** @class */ (function () {
2511
2521
  cleanupIndexes.push(index);
2512
2522
  return false;
2513
2523
  }
2514
- // find item by title
2515
- var findItem = _this.config.columns.find(function (column) {
2516
- return column.title && column.title.length && _this._translateService.instant(column.title) === headerItem;
2517
- });
2518
2524
  // exclude hidden columns
2519
- if (findItem && findItem.hidden === true) {
2525
+ // note: use the datatable visible() function
2526
+ // instead of the hidden config property, to satisfy the column selector
2527
+ if (!_this.dataTable.column(index).visible()) {
2520
2528
  cleanupIndexes.push(index);
2521
2529
  return false;
2522
2530
  }
@@ -5351,7 +5359,10 @@ var AdvancedTableState = /** @class */ (function () {
5351
5359
  this.table.stateSave = true;
5352
5360
  this.table.stateLoadCallback = function (settings, callback) {
5353
5361
  _this.store.pipe(select(selectTable, { id: _this.tableState }), first()).subscribe(function (state) {
5354
- return callback(state && state.table);
5362
+ callback(state && state.table);
5363
+ if (state && state.table && state.table.ColReorder) {
5364
+ _this.table.dataTable.colReorder.order(state.table.ColReorder, true);
5365
+ }
5355
5366
  });
5356
5367
  };
5357
5368
  var firstDraw = true;