Skip to content

Filter doesn't move to first page #339

@gzai

Description

@gzai

There is an issue with filtering when using pagination.

The filter work on first page. but after click page and select filter, datatable doesn't move to first page.

When I look at https://livewire-datatables.com/relation, after set filter on page 2, datatable move to first page.

How to solve this issue?

bug-filter-move-to-first-page

class DatatableOfUsers extends LivewireDatatable
{

	public $exportable = true;

    public function builder()
    {
        return User::query();
    }

    public function columns()
    {
        return [
            NumberColumn::name('id')
                ->label('ID')
                ->defaultSort('asc')
                ->sortBy('id')
                ->hide(),

            Column::name('name')
                ->label('Name')
                ->searchable(),

            Column::name('email')
                ->label('Email')
                ->searchable(),

            Column::name('roles.name')
            	->filterOn('roles.name')
            	->filterable( $this->roles->pluck('name') )
            	->label('role'),

            DateColumn::name('created_at')
                ->label('Created at')
        ];
    }

    public function getRolesProperty()
    {
        return Role::all();
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions