Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rocky2023's avatar

yajra datatables searching for comma separated roles not working

Need to achieve global searching as shown here in the permission column of datatable put https in front ://datatables.net/extensions/searchpanes/examples/advanced/renderSearchArrays.html

How can I achieve same behavior with YAJRA Datatable everything is working except render

In jquery datatable render mentioned as

render: {
                    _: '[, ].name',
                    sp: '[].name'
                },

In yajra datatable it is not working and results in Undefined array key 0

->render([
                    '_' => '[, ].name',
                ])

Does anyone know how to fix this? my expected result is to show data for comma-separated values and perform a global search on them as well

0 likes
1 reply
rocky2023's avatar

Finally, I found how we can access comma-separated values by searching

->addColumn('role', function (User $user) {
                return implode(', ', $user->getRoleNames()->toArray());
            })
->filterColumn('role', function ($query, $keyword) {
                $query->whereHas('roles', function ($q) use ($keyword) {
                    $q->whereRaw("roles.name like ?", ["%$keyword%"]);
                });
            })

Please or to participate in this conversation.