Search code examples
datatablesyadcf

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.


Solution

  • 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