Index Ordering

By default CRUD indexes pages will be ordered by id in descending order.

You can change the default order:

$this->order('name', 'ASC');

By default users can click on column headings to reorder the table. You can disable this for specific columns:

(new Text('column_name'))
    ->orderableBy(null),

Or you can make ordering on a column order by another column behind the scenes. This is useful if the column is some kind of formatted data.

(new Text('some_date_readable'))
    ->orderableBy('some_date'),

You can also make this use multiple columns - just comma separate them.

Just one caveat - both of the columns will use the same asc/desc setting. There is no way to make, for example, text_field be asc while other_text_field is desc.

(new Text('combined_text'))
    ->orderableBy('text_field,other_text_field'),

Order Column Scopes

If an orderable column relies on a relationship, you will need to join the related table.

See Index Scopes

Manual ordering (drag and drop)

You can also let users drag and drop a table to reorder it.

$this->orderable()

By default this will use the order column to store the order of items. You can specify a different column if you need. It should be an integer column.

$this->orderable('my_special_order')

I'm not sure how well this plays with index reordering... @todo