MedicOneSystems / MedicOneSystems/livewire-datatables
Sorting not working properly
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
I've been trying to sort the datatables on my project by a certain hidden column - in this case it was "created_at". I had attempted a number of methods and strangely, the only thing that seemed to ever behave correctly was the flag for "asc" or "desc".
For instance, I tried to use the props...
<livewire:tables.companies :excludeTrashed=true sort="created_at|asc"/>
Whether or not the column was visible, it would simply sort by name ascending or descending, although it did change depending on if I used "asc" or "desc" in the props. I also tried setting a public $sort which ended up with similar results. I even tried using the sortBy column method to absolutely no avail.
DateColumn::name('created_at')
->label('Created At')
->sortBy('DATE_FORMAT')
->hide()
I also tried making it searchable and simply just referring to it as if it were a regular column, none of which worked. I can also verify that even filtering by name didn't return the desired data because I had cross-compared what the datatable returned against DataGrip only to find that the ordering was wrong.
Any help would be muchly appreciated, thanks!
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the reported sort on the livewire:tables.companies component with the hidden created_at column. Inspect the DateColumn configuration and sortBy('DATE_FORMAT') usage, then compare the returned order with the database. Done means ascending and descending sorting consistently use created_at rather than the name column.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100