sort method

void sort(
  1. List<DaviSort> newSortList
)

Defines the columns that will be used in sorting.

If multi sorting is disabled, only the first one in the list will be used. Not sortable columns will be ignored.

Implementation

void sort(List<DaviSort> newSortList) {
  if (const ListEquality().equals(sortList, newSortList)) {
    // same sort
    return;
  }

  _clearColumnsSortData();
  HashSet<dynamic> uniqueColumnIds = HashSet<dynamic>();
  int priority = 1;
  for (DaviSort sort in newSortList) {
    if (!uniqueColumnIds.add(sort.columnId)) {
      throw ArgumentError(
          'List has multiple configurations with the same columnId.');
    }
    DaviColumn<DATA>? column = getColumn(sort.columnId);
    if (column != null && column.sortable) {
      column.setSort(sort, priority++);
      if (!multiSortEnabled) {
        // only the first one
        break;
      }
    }
  }
  _ensureSort();
  _updateRows(notify: true);
  _notifyOnSort();
}