defaultOrdering

defaultOrdering(string $ordering[, string $sorting])

The default ordering that the datagrid will have before the user will press any button to order by column.

Example:

$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');
$crud->columns(['customerName','phone','addressLine1','creditLimit']);

$crud->defaultOrdering('customers.country', 'desc');

$output = $crud->render();

You can also have multiple default ordering by adding an array.

Example

$crud->setTable('customers');
$crud->setSubject('Customer', 'Customers');
$crud->columns(['customerName','phone','addressLine1','creditLimit']);

$crud->defaultOrdering([
   'customerName' => 'ASC',
   'customerSurname' => 'DESC'
]);

$output = $crud->render();