Victorio Berra
Victorio Berra

Reputation: 3125

How can I trim text in YADCF before server-side filtering/searching happens?

I am using a server-side jQuery DataTable.

I have a filter that looks like this:

{
    column_selector: '.FirstName',
    filter_default_label: 'First Name',
    style_class: 'form-control',
    filter_type: 'text',
    filter_reset_button_text: false,
    filter_delay: 1000
}

When someone pastes "hello world " it searches that on my server including the trailing space.

What I need is a function that I can apply before filtering. I went through the code https://github.com/vedmack/yadcf/blob/master/src/jquery.dataTables.yadcf.js and theres a few functions but they all seem to have to do with selects. IE custom_func is only for when filter_type is custom_func / multi_select_custom_func / date_custom_func according to the docs in the code.

Perhaps I need to tap into jQuery DataTables? https://www.datatables.net/reference/option/ I dont see an option to format search stuff before it gets sent to my server.

Lastly, should I do the trimming on my server and ignore the front-end?

Upvotes: 0

Views: 103

Answers (0)

Related Questions