@wavemaker/app-ng-runtime 11.4.0-next.1417030 → 11.4.0-next.1417032

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.
@@ -534,14 +534,13 @@ $.widget('wm.datatable', {
534
534
 
535
535
  /* Returns the tbody markup. */
536
536
  _getGridTemplate: function () {
537
- var self = this, preparedData,$tbody, tbodyExists,pageStartIndex = self.getPageStartIndex(),
537
+ var self = this, preparedData,$tbody,pageStartIndex = self.getPageStartIndex(),
538
538
  startRowIndex = self.options.startRowIndex,
539
539
  isScrollorOnDemand = self.options.isNavTypeScrollOrOndemand();
540
540
  if(isScrollorOnDemand) {
541
541
  $tbody = this.gridElement;
542
542
  } else {
543
- tbodyExists = this.gridElement.find('tbody').length;
544
- $tbody = tbodyExists > 0 ? this.gridElement.find('tbody:first') : this.gridElement.empty();
543
+ $tbody = this.gridElement.empty();
545
544
  }
546
545
 
547
546
  if(isScrollorOnDemand) {
@@ -1422,6 +1421,9 @@ $.widget('wm.datatable', {
1422
1421
  this.selectFirstRow(value);
1423
1422
  break;
1424
1423
  case 'data':
1424
+ if(!this.isResetSortIconsDone) {
1425
+ this.setSortIconDefault();
1426
+ }
1425
1427
  this.refreshGridData();
1426
1428
  break;
1427
1429
  case 'dataStates':
@@ -2375,6 +2377,7 @@ $.widget('wm.datatable', {
2375
2377
  },
2376
2378
  //Method to remove sort icons from the column header cells
2377
2379
  resetSortIcons: function ($el) {
2380
+ this.isResetSortIconsDone = true;
2378
2381
  var $sortContainer;
2379
2382
  //If sort icon is not passed, find out the sort icon from the active class
2380
2383
  if (!$el && this.gridHeaderElement) {
@@ -2384,9 +2387,25 @@ $.widget('wm.datatable', {
2384
2387
  }
2385
2388
  $el.removeClass('desc asc').removeClass(this.options.cssClassNames.descIcon).removeClass(this.options.cssClassNames.ascIcon);
2386
2389
  },
2390
+ setSortIconDefault: function() {
2391
+ const sortInfo = this.options.sortInfo,
2392
+ $e = this.tableContainer,
2393
+ $th = $e.find("[data-col-field='" + sortInfo.field + "']"),
2394
+ $sortContainer = $th.find('.sort-buttons-container'),
2395
+ $sortIcon = $sortContainer.find('i.sort-icon'),
2396
+ direction = sortInfo.direction;
2397
+ if (direction === 'asc') {
2398
+ $sortIcon.addClass(direction + ' ' + this.options.cssClassNames.ascIcon);
2399
+ $sortContainer.addClass('active');
2400
+ } else if (direction === 'desc'){
2401
+ $sortIcon.addClass(direction + ' ' + this.options.cssClassNames.descIcon);
2402
+ $sortContainer.addClass('active');
2403
+ }
2404
+
2405
+ },
2387
2406
  /* Handles table sorting. */
2388
2407
  sortHandler: function (e) {
2389
- e.stopImmediatePropagation();
2408
+ e.stopImmediatePropagation();
2390
2409
  // If header span is clicked and column selection is enabled, call header click
2391
2410
  if ($(e.target).hasClass('header-data') && this.options.enableColumnSelection) {
2392
2411
  this.headerClickHandler(e);
@@ -2396,7 +2415,7 @@ $.widget('wm.datatable', {
2396
2415
  id = $th.attr('data-col-id'),
2397
2416
  $sortContainer = $th.find('.sort-buttons-container'),
2398
2417
  $sortIcon = $sortContainer.find('i.sort-icon'),
2399
- direction = $sortIcon.hasClass('asc') ? 'desc' : $sortIcon.hasClass('desc') ? '' : 'asc',
2418
+ direction = $sortIcon.hasClass('asc') ? 'desc' : 'asc',
2400
2419
  sortInfo = this.options.sortInfo,
2401
2420
  $previousSortMarker = this.gridHeaderElement.find('.sort-buttons-container.active'),
2402
2421
  field = $th.attr('data-col-field'),
@@ -2999,6 +3018,9 @@ $.widget('wm.datatable', {
2999
3018
  }
3000
3019
  });
3001
3020
  }
3021
+ if(!this.isResetSortIconsDone) {
3022
+ this.setSortIconDefault();
3023
+ }
3002
3024
  },
3003
3025
  addOrRemoveScroll: function () {
3004
3026
  var gridContent = this.gridContainer.find('tbody'),