When a user first visits the page, the ListEntries
table is ordered ascending by id and none of the ordering icons in the table header are active.
I would like to have the ListEntries
table ordered by a column of my choosing, including having the icon next to this column active (either ascending or descending).
Is there a way to have the ListEntries
table ordered by a column of my choosing when a user visits the page?
In your Controller's setup()
method you can use:
$this->crud->orderBy('name', 'DESC');
Anything you pass to the orderBy()
statement will be used on the Eloquent query.
By default, columns for real attributes (that have a correspondent column in the database) should be orderable
. But you can also manually specify 'orderable' => true
for columns, or define your own order logic. Note that relationship columns (1-n, n-n), model_function
or model_function
columns are NOT orderable by default, but you can make them orderable with orderLogic
.
Hope it helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With