简体   繁体   中英

Yadcf - Server side multi select

I used the function yadcf multi_select When I make my search for two words, the function puts me a pipe between. I do not know how to remove it for that he understands the two words separately.

http://www.hostingpics.net/viewer.php?id=710742Capture.jpg

I found that the pipe would begin with this function :

 function doFilterMultiSelect(arg, table_selector_jq_friendly, column_number, filter_match_mode) { $.fn.dataTableExt.iApiIndex = oTablesIndex[table_selector_jq_friendly]; var oTable = oTables[table_selector_jq_friendly], selected_values = $(arg).val(), selected_values_trimmed = [], i, stringForSearch, column_number_filter, settingsDt = getSettingsObjFromTable(oTable); column_number_filter = calcColumnNumberFilter(settingsDt, column_number, table_selector_jq_friendly); $(document).data("#yadcf-filter-" + table_selector_jq_friendly + "-" + column_number + "_val", selected_values); if (selected_values !== null) { for (i = selected_values.length - 1; i >= 0; i--) { if (selected_values[i] === "-1") { selected_values.splice(i, 1); break; } } for (i = 0; i < selected_values.length; i++) { selected_values_trimmed.push($.trim(selected_values[i])); } if (selected_values_trimmed.length !== 0) { stringForSearch = selected_values_trimmed.join('narutouzomaki'); stringForSearch = stringForSearch.replace(/([.*+?^=!:${}()|\\[\\]\\/\\\\])/g, "\\\\$1"); stringForSearch = stringForSearch.split('narutouzomaki').join('|'); if (filter_match_mode === "contains") { oTable.fnFilter(stringForSearch, column_number_filter, true, false, true); } else if (filter_match_mode === "exact") { oTable.fnFilter("^(" + stringForSearch + ")$", column_number_filter, true, false, true); } else if (filter_match_mode === "startsWith") { oTable.fnFilter("^(" + stringForSearch + ")", column_number_filter, true, false, true); } else if (filter_match_mode === "regex") { oTable.fnFilter(stringForSearch, column_number_filter, true, false, true); } } else { oTable.fnFilter("", column_number_filter); } } else { oTable.fnFilter("", column_number_filter); } resetIApiIndex(); } 

I can not seem to solve the problem to operate the multi_select.

Thank you for the help

Since you are using a multi select filter on some column yadcf sends strings with | (OR) to your server.

On your server side you have to do the split of the string into array/list of string and construct a proper sql query.

Split in Java

Split in PHP(see code sample in bottom

ps I'm the author of yadcf

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM