Sorting
A dataset owns one active sort definition. Sorting applies to the active logical view and integrates with local data as well as adapter-backed paging.
Set sort descriptors directly
await dataSet.sort.set([
const FdcDataSetSort(
fieldName: 'name',
sortType: FdcSortType.ascending,
),
]);
Use descriptor lists when sort state comes from configuration, persisted layout, or other dynamic input.
Build multi-field sorting
await dataSet.sort
.sortBy('last_name').ascending
.sortBy('first_name').ascending
.apply();
Direction properties build the expression. apply() validates and applies the complete sort in one operation.
Toggle a field
For simple column-style sorting behavior:
await dataSet.sort.toggleBy('name');
If the field is not already the primary sort, the first direction is ascending. Repeating the operation toggles the primary direction.
Clear sorting
await dataSet.sort.clear();
Inspect active sorting
final sorts = dataSet.sort.items;
final active = dataSet.sort.active;
Sorting with paging
For adapter-backed paging, sorting belongs to the adapter query. The adapter must apply the complete ordering before offset and limit; sorting only the currently loaded page would produce incorrect page boundaries.