How to set Default Filter Value columnDefs for Server Side Filter

How to set Default Filter Value columnDefs for Server Side Filter

venkatesanvenkatesan Posts: 3Questions: 2Answers: 0

I m trying to Initialize Datatable Like Below code

 $('#' + tableid).DataTable(
            {
                "columnDefs": [
                    {
                        "targets": [0],
                        "visible": true,
                        "searchable": false
                    },
                ]
            }
        );

While Adding Column Defenition. I want to add Default Value For Filteration. Somthing Like

{
"targets": [0],
"visible": true,
"searchable": false,
** "value" : 21**
},

On the above "value" added for just showing, and aware Property not present. So is there any way I can Use like that.

Thanks Advance.

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    Hi @venkatesan ,

    You just need to use search,

    Cheers,

    Colin

  • venkatesanvenkatesan Posts: 3Questions: 2Answers: 0

    Tq.
    I have got a solution to Use for separate column also.

    $('#example').dataTable( {
      "searchCols": [
        null,
        { "search": "My filter" },
        null,
        { "search": "^[0-9]", "escapeRegex": false }
      ]
    } );
    
This discussion has been closed.