I'm using datatables and yadcf on my website. Everything is working fine. In some cases I want to prefilter a column.
yadcf.init(oTable, [ {
column_number : 1,
filter_default_label : "",
filter_reset_button_text : false,
filter_type : "multi_select",
select_type : 'select2'
}, {
column_number : 2,
filter_default_label : "",
filter_reset_button_text : false,
filter_type : "multi_select",
select_type : 'select2'
}, {
column_number : 3,
filter_default_label : "",
filter_reset_button_text : false,
filter_type : "multi_select",
select_type : 'select2'
}, {
column_number : 5,
filter_default_label : "",
filter_reset_button_text : false,
filter_type : "multi_select",
select_type : 'select2'
}, {
column_number : 6,
filter_default_label : "",
filter_reset_button_text : false,
filter_type : "multi_select",
select_type : 'select2'
} ]);
Until this point everything works fine. But when I add:
yadcf.exFilterColumn(oTable, [[3, 'WNC402']]);
there does not appear any filter. The console output error is:
jquery.dataTables.yadcf.js:688 Uncaught TypeError: selected_value.join is not a function
at yadcfMatchFilterString (jquery.dataTables.yadcf.js:688)
at Object.exFilterColumn (jquery.dataTables.yadcf.js:3792)
at HTMLDocument.<anonymous>
at i (jquery-2.2.4.min.js:2)
at Object.fireWith [as resolveWith] (jquery-2.2.4.min.js:2)
at Function.ready (jquery-2.2.4.min.js:2)
at HTMLDocument.J (jquery-2.2.4.min.js:2)
the site still loads properly and I even can set the filters manually. But the function should do the job.
my datatables version is: 1.10.12
my yadcf version is: 0.8.9
some links:
https://github.com/vedmack/yadcf
Thank you.
Please read the docs and the usage example of filtering mutiselect column
yadcf.exFilterColumn(oTable, [[0, ['Some Data 1','Some Data 2']]]); // for pre filtering multi select filter you should use array with values (or an array with single value)
Since its a multi select filter you have to provide the filter value inside an array.