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

Filter relationship by Yajra laravel-datatable serverside searchbuilder #2726

Closed
enaeim opened this issue Jan 12, 2022 · 7 comments
Closed
Labels

Comments

@enaeim
Copy link

enaeim commented Jan 12, 2022

Hi friends.
I Use Yajra/laravel-datatable to datatable server side and datatables searchbuilder extension for serverside filter. And this work correctly.
But how to add a relationship field to searchbuilder. For example, in my project, in the admin panel, there is a table containing all the admins of the site and there is no column as the their roles. But I want to search and find users who are operators in searchbuilder. How do I implement this using searchbuilder and yajra?
I am new to datatables, yajra and jquery.
I would be very grateful if you could guide me or introduce me to the tutorial link or in-depth tutorial on this.
Thanks a lot.

Originally posted by @enaeim in #2648 (comment)

@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Oct 19, 2022
@yajra
Copy link
Owner

yajra commented Oct 19, 2022

You can use filterColumn

    return DataTables::eloquent($model)
                ->filterColumn('relation_name', function($query, $keyword) {
                    $query->whereHas('relation', fn($q) => $q->where('relation_name', $keyword));
                })
                ->toJson();

@github-actions github-actions bot removed the stale label Oct 20, 2022
@github-actions
Copy link

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the stale label Nov 20, 2022
@github-actions
Copy link

This issue was closed because it has been inactive for 7 days since being marked as stale.

@humbertleonardo
Copy link

@enaeim Could you teach me how to use SearchBuilder together with the ServerSide option? I've analyzed Issue #2648 but I still can't get it to work

@enaeim
Copy link
Author

enaeim commented Nov 29, 2022

@enaeim Could you teach me how to use SearchBuilder together with the ServerSide option? I've analyzed Issue #2648 but I still can't get it to work

Hello. Yes I can. But not now. I will get back to you within the next few days.

@humbertleonardo
Copy link

@enaeim Could you teach me how to use SearchBuilder together with the ServerSide option? I've analyzed Issue #2648 but I still can't get it to work

Hello. Yes I can. But not now. I will get back to you within the next few days.

Okay, thank you very much for your attention. If you can make the code you implemented available in some repository, I can try to do it myself

@github-actions github-actions bot locked and limited conversation to collaborators Dec 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants