Filtering out HTML in searches

Filtering out HTML in searches

Da9LDa9L Posts: 4Questions: 2Answers: 0

I'm using DataTables 1.10 along with its search function. In my table i have some html including a button in two cells. The text on said button is dynamic and therefore needs to be searchable, however i want to exclude the content of the button tags around it. Consider the following example

<td data-order="9000000000">
    <button name="num[123]" class="btn btn-default">Dynamic Text</button>

When i use the search function over the table and search for "123" the row with the above cell and button is shown. From a user perspective this is quite confusing as nothing is actually shown to include 123.

Can i somehow make the search function not search inside the button tag, but only the actualy text (Dynamic Text) ?


  • Da9LDa9L Posts: 4Questions: 2Answers: 0

    Okay I'm feeling a bit foolish. I had been trying to get this to work, but didn't realize that it was working in the wrong file. As soon as I moved the following code to the file i was actually testing on it worked

                "columns": [
                    { "width": "35%", "searchable": true, "type": "html" },
                    { "width": "25%", "searchable": true, "type": "html" },
                    { "width": "25%", "searchable": true, "type": "html" },
                    { "width": "5%", "searchable": true, "type": "html" },
                    { "width": "5%", "searchable": true, "type": "html" },
                    { "width": "5%", "orderable" : false, "searchable": false, "type": "html" }
Sign In or Register to comment.