Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default sort #22

Open
snapey opened this issue May 5, 2020 · 3 comments
Open

Default sort #22

snapey opened this issue May 5, 2020 · 3 comments

Comments

@snapey
Copy link

snapey commented May 5, 2020

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.

@snapey
Copy link
Author

snapey commented May 5, 2020

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';
    }

@mkysoft
Copy link

mkysoft commented Sep 13, 2020

You can use default variables like below:

class UsersTable extends TableComponent
{
    public $sortField = 'id';

    public $sortDirection = 'desc';
}

@nguillaumin
Copy link

What works for me is:

    public string $defaultSortColumn = 'id';
    public string $defaultSortDirection = 'desc';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants