Skip to content

fix: implement server-side sorting for customers grid#137

Merged
biz87 merged 1 commit intobetafrom
fix/customers-grid-sorting
Mar 10, 2026
Merged

fix: implement server-side sorting for customers grid#137
biz87 merged 1 commit intobetafrom
fix/customers-grid-sorting

Conversation

@biz87
Copy link
Copy Markdown
Member

@biz87 biz87 commented Mar 10, 2026

Summary

  • Sorting in customers grid was visual-only — PrimeVue DataTable showed sort icons but data never actually sorted
  • Root cause: CustomersController::getList() had hardcoded sortby: 'id' and passed sort/limit options as 3rd argument to getIterator(), which is actually $cacheFlag — so sorting AND pagination were silently ignored
  • Also: CustomersGrid.vue never sent sort/dir parameters to the API

Changes

CustomersController.php:

  • getIterator($class, $criteria, $options)newQuery() + $c->sortby() + $c->limit()
  • Accept sort/dir URL parameters
  • mapSortField() whitelist for safe ORDER BY (prevents SQL injection)
  • strposstr_starts_with (PHP 8.2+)

CustomersGrid.vue:

  • Add sortField/sortOrder refs, onSort handler
  • Bind :sort-field/:sort-order and @sort on DataTable
  • Pass sort/dir in API request params

Test plan

  • Click sortable column headers in customers grid — data should re-sort
  • Verify sort direction toggles (ASC/DESC) with repeated clicks
  • Verify pagination works correctly after sorting
  • Verify non-sortable columns (e.g. template fields) don't trigger sort
  • Verify search + sort work together

CustomersGrid.vue: add sort state, onSort handler, pass sort/dir params.
CustomersController: replace hardcoded getIterator options (which were
passed as cacheFlag) with proper newQuery + sortby/limit. Add
mapSortField whitelist for safe ORDER BY. Also fixes server-side
pagination which was silently broken.
@biz87 biz87 merged commit 4163aed into beta Mar 10, 2026
@Ibochkarev Ibochkarev deleted the fix/customers-grid-sorting branch March 16, 2026 07:09
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