UNPKG

@true-directive/base

Version:

The set of base classes for the TrueDirective Grid

50 lines (49 loc) 1.81 kB
/** * Copyright (c) 2018-2019 Aleksey Melnikov, True Directive Company. * @link https://truedirective.com/ * @license MIT */ // Тип сортировки export var SortType; (function (SortType) { SortType["NONE"] = "None"; SortType["ASC"] = "ASC"; SortType["DESC"] = "DESC"; })(SortType || (SortType = {})); // Информация о сортировке грида var SortInfo = /** @class */ (function () { function SortInfo(fieldName, sortType) { this.fieldName = fieldName; this.sortType = sortType; } SortInfo.prototype.set = function (fieldName, sortType) { this.fieldName = fieldName; this.sortType = sortType; }; SortInfo.prototype.invert = function () { if (this.sortType === SortType.NONE) { this.sortType = SortType.ASC; } else { this.sortType = this.sortType === SortType.ASC ? SortType.DESC : SortType.NONE; } // Можно сделать так, чтобы клик по колонке, которая отсортирована в обратном порядке // сортировалась в прямом порядке: // this.sortType = this.sortType === SortType.ASC ? SortType.DESC : SortType.ASC; }; SortInfo.prototype.sort = function (fieldName) { if (this.sortType === SortType.ASC && this.fieldName === fieldName) { this.sortType = SortType.DESC; } else { this.fieldName = fieldName; this.sortType = SortType.ASC; } }; SortInfo.prototype.toString = function () { var st = this.sortType + ''; return this.fieldName + " " + st; }; return SortInfo; }()); export { SortInfo };