Provide a way to define a default ordering inside ListOperation
See original GitHub issueFeature Request
What’s the feature you think Backpack should have?
A way to specify a default sort column for a list operation, eg.
Have you already implemented a prototype solution, for your own project?
I’ve tried a couple methods but they don’t work, eg.
- https://stackoverflow.com/a/63831852
- https://stackoverflow.com/a/57293048
- Even various combinations of both.
These don’t work at all for me, possibly because tables are too “sticky”. Even when I reset filters and manually set persistent-table=false
in the URL, the last sorted column is always what’s sorted by. AJAX requests seem to always have order[0][column]: 1
and order[0][dir]: desc
set.
I’ve even tried deleting my domain cookies and logging back in again to a “fresh” table, and it’s still sticky.
Even if these methods did work, they feel very hacky. For the first example especially, since we have to find the index of the column we want to sort by (we can’t reference it by name).
Do you see this as a core feature or an add-on?
Core.
Thanks. 🙏
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to add a default ordering of ListEntries table in Backpack ...
In your Controller's setup() method you can use: $this->crud->orderBy('name', 'DESC');. Anything you pass to the orderBy() statement will be ...
Read more >Default Sort of the records in list view - ServiceNow Community
Solved: I want to make default sort on "SortNum" column for all the user, how can we achieve that. @Ankur Bawiskar.
Read more >List Operation :: 5.x Docs - Backpack for Laravel
Starting with Backpack v5.4 we have an easy way to disable both of those, in order to make the ListOperation super-fast on big...
Read more >Default sorting order in data grid 2 | Mendix Forum
Hey, Is there a way to change the default sorting order in a datagrid 2. As a example: I have a datagrid 2...
Read more >ListObjectsV2 - Amazon Simple Storage Service
Objects are returned sorted in an ascending order of the respective key names in the ... The owner field is not present in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t think it’s properly documented, no. @pxpm could you please create a first draft for docs for this, and tag me to take a second look? 🙏
Hello @joelmellon sorry for the time it took to get back here.
Usually column
0
it’s the model primary column that Backpack automatically adds when developer don’t manually specify it. By default, if you don’t apply any order to the table, Backpack will apply the “default order” that isprimaryKey => DESC
so that you get the last created items first.You can change the order by applying your custom orders to any other columns, so Backpack will apply your orders first, and on top of that, the primary key order. You can also add your custom primary key orderBy, to override Backpack defaults.
The orderBy’s are applied on database level so they cannot be “model attributes”, but must be “table columns”.
The reset button does not reset
query orders
, only resetstable orders/filters
, so if you don’t apply any order, like I told you Backpack will apply the “orderBy primary key” in thequery orders
.If in you controller you have something like:
This is a
query order
, the reset button will not reset this order.I hope I made myself clear enough here, so I will be closing this, let me know if I missed something so that I can re-open if needed.
Cheers