How to ignore first tr in search in jquery.datatables?

0

I have a table where the first <tr> I put an image, if when I go to search comes the image name together.

For example: in the first line of the table the img is named head.png and the rest of the line does not have the p letter.

But when I search for "p" the search shows me the first line.

But when I put at least one line without img it can search.

    
asked by anonymous 02.12.2017 / 01:00

1 answer

0

Update 12/24/2017

You can control what is searched (and even what is ordered) through the option columns.render .

In this case, you must pass a function and treat when the second parameter type has the content filter . The fourth parameter meta can help determine what the line is without depending on some additional data in the table, since meta.row is the index of the line.

It would look something like this:

render: function (data, type, row, meta) {
    if (type == "filter" && meta.row == 0)
        return "Texto customizado"; //aqui fica a seu critério o valor que será pesquisado

    return data;
}

Original answer

You can control what is searched (and even what is ordered) through the option columns.render .

In this case, you must pass a function and treat when the second parameter type has the content filter . It would look something like this:

render: function (data, type) {
    if (type == "display")
        return data;
    else if (type == "filter")
        return "Texto customizado";
}
    
21.12.2017 / 01:51