laravel-livewire-tables
laravel-livewire-tables copied to clipboard
Default sort
Is there a way to add a default sort to the view? I can't add it to the query as then it overrides the ability to sort by the other columns later.
I don't know if this is correct, but I overwrote the defaults in the mount method;
public function mount()
{
$this->setTableProperties();
$this->sort_attribute = 'name';
$this->sort_direction = 'asc';
}
You can use default variables like below:
class UsersTable extends TableComponent
{
public $sortField = 'id';
public $sortDirection = 'desc';
}
What works for me is:
public string $defaultSortColumn = 'id';
public string $defaultSortDirection = 'desc';