Change quick search filter behavior when using callbackColumn

Hi @johnny !

I would like to change the quick search behavior of a column when I use callbackColumn() to change the way I display data in the grid.
For example, if the original values in a column are comma separated ids I can use a callbackColumn() to retrieve their names (instead of showing the ids). In this case the quick search won’t work as expected (by the user), I mean, the user will not be able to search by name (only by ids like: “53, 61”, “76”).

Could you please show me a way to use the results from callbackColumn() in the quick search filter instead of original database values (ids in my case).

Thx.

PS.: can’t change db schema to use a n-to-n relation.

Hello @bgeneto ,

Not sure if this fits your needs but what if you use fieldTypeSearchColumn to change the search into a dropdown with your own model?

For example:

$crud->fieldTypeSearchColumn('contact_title', 'dropdown_search', [
    '12' => 'Master',
    '13' => 'Mr',
    '14' => 'Miss',
    '15' => 'Mrs',
    '16' => 'Missus',
    '17' => 'Ms',
    '18' => 'Mx'
]);

For more you can also check the official documentation here: fieldTypeSearchColumn - Grocery CRUD - A PHP CRUD Generator Library

1 Like

Thank you so much! I knew the child’s father would have a practical solution to this problem :slight_smile:

May I jump in this question. Given your example in the link, how shall we search for a 'contactLastName' where the dropdown is not really an option if you have plenty of customers. Could you extend your example a bit please?

I’m currently using ‘dropdown_search’ with thousands of values (retrieved from my model/database) and it works fine.

A minor issue/side effect of this workaround is that the advanced filter button (not quick search) only have a limited number of matching options like those in fig. below:

image

Those options below is not available in this case (unfortunately):

image

But quick search with ‘dropdown_search’ matches partial strings already, not a big issue indeed.

I’m talking of a database with nearly half a million records which is joined to a table plus some more joins to nearly equal number of other records and this is what makes me concern. If i put all this data in dropdown fields it’s not only the mass amount of data crossing but also a security issue as someone could easily read the whole database. Are my thoughts right?

1 Like