0

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

Vao Tsun
  • 47,234
  • 13
  • 100
  • 132
Nophi
  • 1
  • 1

1 Answers1

0

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

p.s I'm the author of yadcf

Community
  • 1
  • 1
Daniel
  • 36,833
  • 10
  • 119
  • 200
  • Thank you for your answer, I can not apply the split of the string in my server side. I do not know where to put the php code to split words, I try since one week to find the code, but I can not (sorry for my bad english) – Nophi Oct 05 '15 at 16:08