question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Disable default order by model key

See original GitHub issue

Bug report

What I did

reading the list operation code

What I expected to happen

code should be correct

What happened

it seem variable not capture as reference

What I’ve already tried to fix it

nothing

Backpack, Laravel, PHP, DB version

not sure

in this file:https://github.com/Laravel-Backpack/CRUD/blob/master/src/app/Http/Controllers/Operations/ListOperation.php in search function:

collect($orderBy)->each(function ($item, $key) use ($hasOrderByPrimaryKey) {
            if (! isset($item['column'])) {
                return false;
            }

            if ($item['column'] == $this->crud->model->getKeyName()) {
                $hasOrderByPrimaryKey = true;

                return false;
            }
        });

i think variable $hasOrderByPrimaryKey should pass as reference &$hasOrderByPrimaryKey to work at $hasOrderByPrimaryKey = true; command.

Btw, is there anyway to disable order by?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
phammanh029commented, Jan 8, 2021

@promatik i think it works now. Thanks.

Can you please give us an example why you’d want to remove the default ordering by model primary key? I don’t remember now. I will update latter on.

0reactions
promatikcommented, Jan 8, 2021

@phammanh029 regarding your question (disable default order by ID) that PR doesn’t solve it.

Can you please give us an example why you’d want to remove the default ordering by model primary key? I’m finding it difficult to see a situation where it could be useful.

Anyway, if there are use cases, we may add an operation setting for that.

Please let me know 🙌

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to disable initial sorting for jquery DataTables?
This answer was a great help but it's worth noting the potential confusion caused. If col 0 is pre-sorted asc and this initial...
Read more >
DataGrid - How to disable default sorting by key
Hello, I have a problem with DataGrid embedded in DropDownBox. Source of grid is list populated by SQL query which is sorted by...
Read more >
CAP NodeJS remove implicit sorting on primary key
We are facing an issue where every service defined in CAP (Nodejs module) returns the result set in sorted order of primary key...
Read more >
Ability to change default sort option on the Issues page - Jira
Currently the default sort option in the Issues view is set to Order by Priority. This default cannot be changed. For projects where...
Read more >
Disable Default Sorting - Ask TOM - Oracle
There is no such THING as a "default sort". The data is *not* coming out in the order of insertion. That is a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found