databable search by only text inside tag

2019-06-02 22:57发布

问题:

I am using datatable 1.9 . I am facing problem in searching. My table look something like this

<'table> <'td> <'div><'span class="inlineEditCategory" >category<'/span><'/div> <'/td> <'/table>

So if I search on the word like div, span then all rows are is shown which should not. I figure out that content between td is being searched. Is their any way to search only the text part.

回答1:

You can use the html filtering plugin.

Include the js file after the inclusion of datatables.js main script.

And the use the plugin like this in your datatable initialization:

$('#example').dataTable({
      "columnDefs": [
        { type: "html", target: 0 }             
      ]      
});

You can also do this with the aoColumn option like this:

$('#example').dataTable( {
    "aoColumns": [
      { "sType": "html" },
      ....
    ]
} );

For more info see the documentation



标签: datatables