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

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.

Related

multi-select options escaping characters

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?

Replace Placeholder on text type

I'm wondering if it's possible to replace the placeholder text of an input..
yadcf.init(myTable, [
{column_number : 0, filter_type: "text", case_insensitive: true, filter_container_id: "pokedex-number-filter", filter_reset_button_text: false, style_class: "form-control"},
{column_number : 1, filter_type: "text", case_insensitive: true, filter_container_id: "pokemon-name-filter", filter_reset_button_text: false, style_class: "form-control"},
{column_number : 2, filter_type: "text", case_insensitive: true, filter_container_id: "pokemon-gen-filter", filter_reset_button_text: false, style_class: "form-control"},
]);
You can user the following
* setDefaults
Description: Set global defaults for all yadcf instances.
Arguments: Object consisting of anything defined under "Global Parameters"
Usage example: yadcf.setDefaults({'language': {'select': 'تحديد قيمة'}});
or you can set per single table, per column using the filter_default_label option
read more inside the yadcf js file

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

yadcf not sorting dropdown list properly

I have tried every option I can think of in configuring both DataTables (capital D) and yadcf but cannot seem to get the select drop down list to list in case-insensitive order.
Setup:
var dTable=$('#bTable').DataTable({
"traditional": false,
"pageLength": 1000,
"jQueryUI": true,
"stateSave": true,
"stateDuration": 60 * 60 * 24,
"processing": true,
"stateLoadParams": function (settings, data) {
lastSearch=data.search.search;
},
"ordering": true,
"processing": true,
"paging": false,
"info": false,
"autoWidth": false,
})
yadcf.init(dTable,[
{column_number : 3, column_data_type: "text", filter_match_mode: "exact", sort_as: "alphaNum", filter_container_id: "hs_clu", filter_reset_button_text: false, style_class: "select-style", filter_default_label: "All"},
],
{ cumulative_filtering: true }
);
When I click on the column header the column data is sorted properly as:
nbmps01
nbmps02
nbmps800
Network-1
Network-2
Network-3
NTPROV
NTSYM
NTWKTRANS
NVAM-CXMT
My dropdown select list is in this order and doesn't seem to be proper:
NTPROV
NTSYM
NTWKTRANS
NVAM-CXMT
Network-1
Network-2
Network-3
nbmps01
nbmps02
nbmps800
I have am at my wits end on this after 2 days of fiddling with it. Does anyone out there have any ideas and are willing to share.
Any help is very much appreciated.
I have improved the alpha numeric sorting in yadcf 0.9.1.beta.5 , now it works as expected.
use sort_as: "alphaNum"
Here is a working jsfiddle link