multi-select options escaping characters - datatables

I have a DOM multi-select filter on a single column in a table. The filter is defined with:
yadcf.init(table, [{
column_number: 1,
filter_type: "multi_select",
select_type: 'select2',
select_type_options: {theme: 'bootstrap', width: '250px'},
}]);
When the select is rendered, then it is escaping characters which appear in the table, such as '>', which means that the filtering does not work.
Does anyone know how to fix this?

Related

yadcf - multi_select with select2 - options dropdown not case sensitive

Will be posible, in yadcf multi_select filter, sort possible option with case insensibility?
Here is my fiddle to explain this.
In column STATUS are 4 possible values: "abs", "off", "OFF" and "ON". In dropdown the options appears in this order: "OFF", "ON", "abs", "off". And my desire is the options appears in this order: "abs", "OFF", "off", "ON".
Thanks in advance one more time.
You can provide you own custom sort function, , use the following attributes for the column sort_as: 'custom', sort_as_custom_func: mySort (where mySort is a sorting function, like this
'use strict';
var oTable = $('#example').DataTable();
var mySort = function(a, b) {
return a.toLowerCase().localeCompare(b.toLowerCase());
};
yadcf.init(oTable, [
{
column_number: 0,
filter_type: 'multi_select',
filter_match_mode: 'exact',
select_type: 'select2',
sort_as: 'custom',
sort_as_custom_func: mySort
},{
column_number: 1,
filter_type: 'text',
}
]);
working jsfiddle

Is possible to filter blank fields on multi_select?

I want to know if its possible to get the rows with empty fields on this columns. I have a fiddle to explain this.
At first column (Status) I have three values (ON, OFF, (EMPTY)). My problem is to get the rows with empty values (Same row as PR00000003, PR00000005) selecting empty value on the filter.
Thanks in advance.
Since there seems to be some sort of issue with yadcf/select2 and empty string for filtering I can suggest the following solutions:
1) Use regex (see this jsfiddle) -
var oTable = $('#example').DataTable();
yadcf.init(oTable, [
{
column_number: 0,
filter_type: 'multi_select',
append_data_to_table_data: 'before',
data: [ {value:'^$', label:'Empty' }],
filter_match_mode: 'regex',
select_type: 'select2'
}]);
2) Use datatables HTML5 data-* attributes ,
3) Use Chosen plugin (IMO Select2 fits datatables/yadcf better) instead of select2
see jsfiddle sample
var oTable = $('#example').DataTable();
yadcf.init(oTable, [
{
column_number: 0,
filter_type: 'multi_select',
append_data_to_table_data: 'before',
data: [ {value:' ', label:'Empty' }],
filter_match_mode: 'exact',
select_type: 'chosen'
}]);
always bet on yadcf

How to customize yadcf plugin to pass my own items in the filter

I am trying to use yadcf plugin for multiselect plugin in my datatable since it is flexible to use.It generates dropdown multiselect filter with values available in perticular row. I want to customize this in such a way to pass my own list and values corresponding to same like (list)but not getting how can i do this. If anyone could guide me in this, I will be grateful for you.
{
column_number: 1,
filter_type: "multi_select",
select_type: 'select2',
filter_reset_button_text: false
}]);
You should use the data property
For example
{
column_number: 1,
filter_type: "multi_select",
select_type: 'select2',
filter_reset_button_text: false,
data: ["value1","value2"]
}
Here is small fragment from the docs (you better read more in order to know about yadcf feature)
* data
Required: false
Type: Array (of string or objects)
Description: When the need of predefined data for filter is needed just use an array of strings ["value1","value2"....] (supported in select / multi_select / auto_complete filters) or
array of objects [{value: 'Some Data 1', label: 'One'}, {value: 'Some Data 3', label: 'Three'}] (supported in select / multi_select filters)
Note: that when filter_type is custom_func / multi_select_custom_func this array will populate the custom filter select element
*

Chaining yadcf multi_select filters together

Is there a way to chain filters together where by filters applied in one column will pre-filter the available filters in other columns? Primarily I'm interested in this from a multi_select standpoint, but it could be universal to all filters types I guess.
For example:
Column 1's data contains:
Oklahoma
Missouri
Utah
Texas
Kansas
Column 2's data contains:
Obama
Romney
From the dataset I know that all Column 1 data that has 'Oklahoma' will always mean that Column 2 will equal 'Romney'. Thus, if I select 'Oklahoma' from a mutli_select, then the drop down for the multi_select for Column 2 should now only show 'Romney'.
Basically, can I pre-filter my filters based on other filters already put in place?
I think you are asking about the cumulative_filtering: true option of yadcf,
See the showcase page and here a code sample:
$(document).ready(function () {
'use strict';
var oTable;
oTable = $('#example').DataTable();
yadcf.init(oTable,
[
{
column_number : 0,
filter_type: "multi_select",
select_type: 'select2'
},
{
column_number: 3,
filter_type: "auto_complete",
text_data_delimiter: ","
},
{
column_number : 4,
filter_type: "multi_select",
select_type: 'select2',
column_data_type: "html",
html_data_type: "text",
filter_default_label: "Select tag"
}
],
{
cumulative_filtering: true
}
);
});
As you see the cumulative_filtering: true is an object property, an object that that is a third argument of the init function, when using the .yadcf([{...}]) api you should pass that object as a second arument to the .yadcf constractor, like this:
.yadcf([{...}], {cumulative_filtering: true})

Uncaught Error: Syntax error, unrecognized expression in Yadcf select type

I am having a problem with select type in Yadcf. It does not allow brackets.
I have this code
{
column_number: 9,
filter_type: 'select',
select_type: "select2",
column_data_type: "html",
html_data_type: "text",
filter_match_mode: "exact",
filter_default_label: "Select status",
},
HTML:
<td>Identified (In progress)</td>
So when page is loaded I have the error
Uncaught Error: Syntax error, unrecognized expression: Identified (In progress)
If I remove brackets select filter works fine and if I write
column_data_type: "text",
The error is gone but I can't filter by this value.
You should set the column_data_type to html only when the content of your <td> elements contains html code, for example <td><span>Identified (In progress)</span></td> and then yadcf will extract the Identified (In progress) from your span.
In you example the content of the <td> is a plain text, so you should declare the column_data_type at all because the default value of column_data_type is text , b.t.w the default of the [html_data_type is text]2 , so you shouldn't set its value too.
So just remove the
column_data_type: "html",
html_data_type: "text",
and it should work as expected
Here is a working jsfiddle (using latest beta version)
yadcf.init(oTable, [{
column_number: 0,
select_type: "select2",
select_type_options: {
width: '200px'
},
filter_match_mode: "exact"
}]);
p.s I'm the author of yadcf plugin
Seems like a bug in yadcf.
Try to use filter_match_mode: "contains" and column_data_type: "text", as shown below:
{
column_number: 9,
filter_type: 'select',
select_type: "select2",
column_data_type: "text",
filter_match_mode: "contains",
filter_default_label: "Select status"
},
See this JSFiddle for demonstration.