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

Feature/multiselect #469

Merged
merged 9 commits into from
Oct 12, 2021
Merged

Conversation

juliomotol
Copy link
Contributor

Continuation of #441

@rappasoft
Copy link
Owner

Doesn't seem to work for me, same issues I was having with the other PR:

Screen.Recording.2021-09-28.at.16.02.02.mov

@juliomotol
Copy link
Contributor Author

Hmmm, its working on my end.

screencast-laravel.test-2021.09.29-09_11_20.mp4

My composer.json looks like this
image

@rappasoft
Copy link
Owner

How is your table set up?

@juliomotol
Copy link
Contributor Author

class MotorcycleTable extends DataTableComponent
{
    public function query()
    {
        return Motorcycle::query()
            ->when($this->getFilter('brands'), fn($query, $brands) => $query->whereIn('brand', $brands));
    }

    public function filters(): array
    {
        return [
            'brands' => Filter::make('Brand')
                ->multiSelect(Motorcycle::distinct()->pluck('brand', 'brand')->toArray()),
        ];
    }

    public function columns(): array
    {
        return [
            Column::make('Brand')
                ->sortable(),
            Column::make('Model')
                ->sortable(),
            Column::make('Displacement')
                ->sortable(),
        ];
    }
}

Also, I'm using calebporzio/sushi for the the models. I'm too lazy to setup the database schema for this 🤣

@rappasoft
Copy link
Owner

I got it to work. I was using this as my example and this option was making it so I couldn't select anything for some reason.

@juliomotol
Copy link
Contributor Author

juliomotol commented Sep 30, 2021

I see, I dont think '' should be allowed as a key for multiselect. What do you think?

@rappasoft
Copy link
Owner

I see, I dont think '' should be allowed as a key for multiselect. What do you think?

No definitely not, that's just what was breaking it for me.

I'll look this over soon in detail and get it merged if all is well.

@rappasoft rappasoft merged commit 3fbb812 into rappasoft:develop Oct 12, 2021
@rappasoft rappasoft mentioned this pull request Oct 13, 2021
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

Successfully merging this pull request may close these issues.

3 participants