Refresh datatable with data - Custom Filter Buttons

Hello,

I have asked a similar question here before here without any response. I am trying to implement custom filter buttons on Grocery Crud enterprise, I managed to do it in Grocery Crud v2 but I am now working with v3 which mostly uses react n its interface. In v2 I was able to trigger change of the filter relating to the search filed with a js code like so:

$('select[name="department_id"]').val(department_id).trigger('change');

But now I cannot use this script as the search fields do not have unique names/ids assigned to them. I was able to make an ajax call for a custom filter button with a post of form data imitating whats posted when a search field changes but am not sure what to do next, I get the filtered data but it does not render in the datatable. Is there a method to re-render/refresh datatable in javascript with the response data from custom filter?

Please someone answer me as this is important for me to move on with this library otherwise it will not be useful for me.

Hello @lev ,

You are unfortunately right. I’ve tried many combinations and there is not way to trigger the change for the quick search value. Mainly because of the architecture of it. I am thinking of creating a function for it like the groceryCrudSetFieldValue

I will try create a function with name: groceryCrudSetQuickSearchValue for the next release which will trigger the quick search value.

I will keep you updated on this one.

Regards
Johnny

Hello Johnny,

Thank you for your reply. I will be looking forward to the new release.

Hello @lev ,

I am glad to inform you that the

groceryCrudSetQuickSearchValue('columnName', 'columnValue')

JavaScript function is now available in version 3.0.17 . In order to enable it you will need to have the publish_events configuration equal to true (default is off)

Let me know if that worked for you.

Regards
Johnny

Hi Johnny,

Thank you, I will set it up and see how it turns out.

Hi @johnny,

The javascript quick-search function works perfectly, thank you!

1 Like