data-* attributes with ajax data

data-* attributes with ajax data

briankatesbriankates Posts: 2Questions: 2Answers: 0

I have an ajax sourced data table that I want to append a data-search / data-filter attribute to. I can do that pretty easily with a row callback:

"createdRow": function ( row, data, index ) {
$('td', row).eq(1).attr("data-search", data.gameNum);
$('td', row).eq(1).attr("data-filter", data.gameNum);
}

What else do I have to do to get the search to pick up these fields?

Thanks.

Answers

  • allanallan Posts: 63,678Questions: 1Answers: 10,497 Site admin

    I would suggest using columns.render as an object rather than trying to write to the DOM - that would add a roundtrip to the DOM that would be a performance hit on large tables.

    Have a look specifically at this section of the documentation.

    Allan

  • bek816bek816 Posts: 5Questions: 2Answers: 1

    Thanks. For now, I "solved" by adding a new, hidden column. Obviously not ideal. I'll look at the documentation.

This discussion has been closed.