Skip to content

fix(Grid): sorting of columns identified by a value selector instead of a fiel#1315

Closed
nebojsa-peric wants to merge 2 commits into
bug/grid-sorting-without-fieldfrom
fix/grid-sorting-value-only-columns
Closed

fix(Grid): sorting of columns identified by a value selector instead of a fiel#1315
nebojsa-peric wants to merge 2 commits into
bug/grid-sorting-without-fieldfrom
fix/grid-sorting-value-only-columns

Conversation

@nebojsa-peric

Copy link
Copy Markdown
Collaborator

Fixes the field-independent parts of #1314 (repro in #1313, included as the first commit).

What's fixed

Sorting for columns identified by a value selector (tpl/expr/computable) instead of a field:

  • Crash: prepareData no longer fabricates a { field: undefined, direction: undefined }
    sorter when the sortField/sortDirection bindings are declared but still empty — this
    previously matched any field-less sortable column (undefined == undefined) and crashed
    renderHeader with direction.toLowerCase().
  • Value-only columns unsortable with sortField/sortDirection bindings: the fabricated
    sorter also discarded the value selector captured on header click, so such columns never
    sorted; clicking them additionally cleared the sortField binding and toggled the direction
    of the previously active sort.
  • Sort identity: a sort is now identified by its (field, value selector) pair instead of
    the field name alone — previously all field-less sortable columns lit up with the sorted
    icon together, and two columns sorting the same field through different selectors hijacked
    each other's direction on click.
  • The sorter fix-up loop in prepareData now also matches columns by sortField and covers
    line0.

Also documents the value and sortValue column properties in the docs column-configuration
table (precedence-neutral wording).

What's deliberately NOT changed: sort key precedence

The sort key is resolved the same way as before:

Column defines Sort key
field only field
value only value
field + value value
sortField (+ field) sortField
sortValue + anything sortValue
sortField + value value (!)

i.e. effectively sortValue > value > sortField > field. Note the last row: an explicit
sortField is silently ignored when the column also has a display value, which makes
sortField unusable exactly where it seems most needed (computed display, raw-data sort).

This also contradicts the current docs (Grid page, Columns section):

Use value for computed display values while keeping field for sorting

which describes yet another rule (field winning over value) that the code has never
implemented. The docs also don't mention sortValue at all (partially addressed here by the
neutral table entries).

Whether the intended precedence is the current one or e.g. sortValue > sortField > value > field
is an open question on the issue — a follow-up PR with the precedence change (a 3-line diff on
top of this one) and the full docs update is prepared and will be opened once that's decided.

…of a field

- prepareData no longer fabricates a { field: undefined, direction: undefined }
  sorter when the sortField/sortDirection bindings are declared but empty; this
  crashed renderHeader (direction.toLowerCase) and silently discarded the value
  selector captured on header click, making value-only columns unsortable
- a sort is now identified by its (field, value selector) pair instead of the
  field name alone, both for the sorted header indicator and for toggling in
  onHeaderClick; previously any field-less sortable column matched a field-less
  sorter (undefined == undefined) and lit up together, and columns sharing a
  field name hijacked each other's sort direction
- clicking a field-less column no longer toggles the sort of the field
  currently stored in the sortField binding
- the sorter fix-up loop in prepareData now also matches columns by sortField
  and covers line0

Sort key precedence is unchanged: sortValue > value > sortField > field.
@nebojsa-peric
nebojsa-peric deleted the branch bug/grid-sorting-without-field July 23, 2026 13:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant