Skip to content

Commit

Permalink
volosoft#1459: implement initial sorting direction
Browse files Browse the repository at this point in the history
  • Loading branch information
ismcagdas committed Mar 29, 2017
1 parent 4609152 commit 15ca9d8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions dev/jquery.jtable.sorting.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
_createHeaderCellForField: function (fieldName, field) {
var $headerCell = base._createHeaderCellForField.apply(this, arguments);
if (this.options.sorting && field.sorting) {
this._makeColumnSortable($headerCell, fieldName);
this._makeColumnSortable($headerCell, fieldName, field.initialSortingDirection);
}

return $headerCell;
Expand Down Expand Up @@ -104,7 +104,7 @@

/* Makes a column sortable.
*************************************************************************/
_makeColumnSortable: function ($columnHeader, fieldName) {
_makeColumnSortable: function ($columnHeader, fieldName, initialSortingDirection) {
var self = this;

$columnHeader
Expand All @@ -119,6 +119,10 @@
self._sortTableByColumn($columnHeader);
});

if(initialSortingDirection){
$columnHeader.addClass('jtable-column-header-sorted-' + initialSortingDirection.toLowerCase());
}

//Set default sorting
$.each(this._lastSorting, function (sortIndex, sortField) {
if (sortField.fieldName == fieldName) {
Expand Down
8 changes: 6 additions & 2 deletions jquery.jtable.js
Original file line number Diff line number Diff line change
Expand Up @@ -4256,7 +4256,7 @@ THE SOFTWARE.
_createHeaderCellForField: function (fieldName, field) {
var $headerCell = base._createHeaderCellForField.apply(this, arguments);
if (this.options.sorting && field.sorting) {
this._makeColumnSortable($headerCell, fieldName);
this._makeColumnSortable($headerCell, fieldName, field.initialSortingDirection);
}

return $headerCell;
Expand Down Expand Up @@ -4303,7 +4303,7 @@ THE SOFTWARE.

/* Makes a column sortable.
*************************************************************************/
_makeColumnSortable: function ($columnHeader, fieldName) {
_makeColumnSortable: function ($columnHeader, fieldName, initialSortingDirection) {
var self = this;

$columnHeader
Expand All @@ -4318,6 +4318,10 @@ THE SOFTWARE.
self._sortTableByColumn($columnHeader);
});

if(initialSortingDirection){
$columnHeader.addClass('jtable-column-header-sorted-' + initialSortingDirection.toLowerCase());
}

//Set default sorting
$.each(this._lastSorting, function (sortIndex, sortField) {
if (sortField.fieldName == fieldName) {
Expand Down

0 comments on commit 15ca9d8

Please sign in to comment.