vedmack / yadcf

Yet Another DataTables Column Filter (yadcf)
http://yadcf-showcase.appspot.com/
MIT License
731 stars 285 forks source link

Using different option value and text for select filter when using columns.data.filter property #604

Closed tanyona closed 4 years ago

tanyona commented 4 years ago

This is related to #581

Would it be possible when using a select filter, to have the select value and the option text be different when using the columns.data property of datatables. Currently, the option text used is from the filter property.

An example jfiddle - https://jsfiddle.net/78xhybqn/1/

Datatables documentation on columns.data - https://datatables.net/reference/option/columns.data

vedmack commented 4 years ago

Yes, see the following example on how to

working test page

var data = [{
    "nameFilter": "one",
    "name": "1"
  },
  {
    "nameFilter": "two",
    "name": "2"
  },
  {
    "nameFilter": "one, two, three",
    "name": "1, 2, 3"
  }
];

var columns = [{
  "data": {
    _: "name",
    filter: "nameFilter",
    display: "nameFilter"
  }
}];

var table = $('#tb');
var dtable = table.DataTable({
  data: data,
  columns: columns
});

yadcf.init(dtable, [{
  column_number: 0,
  text_data_delimiter: ", "
}]);
tanyona commented 4 years ago

I would like the datatables search box to use 1, 2 or 3 as a filter. The idea is that the select displays one, two and three as options, but the search is on 1, 2, 3.