Search is not working on cells that use 'fnCreatedCell'
Search is not working on cells that use 'fnCreatedCell'
caldera500
Posts: 2Questions: 1Answers: 0
The table content gets created as intended. I am just noticing that columns where I manipulate the content with 'fnCreatedCell' are not included in search results. Search works on all other columns:
$('#user_table').DataTable({
ajax: {
url: '/load_users',
dataSrc: ''
},
columns: [
{data: '_id',
"fnCreatedCell": function (nTd, sData, oData, iRow, iCol) {
$(nTd).html('<div class="userdetail" rel="' +oData._id+ '">' +oData.firstName+ ' ' +oData.lastName+ '</div>');
}},
{data: 'local.email'},
{data: '_id'}
]
});
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
This is correct - it would be exceptionally slow for DataTables to read the DOM for the text to search whenever a search was made, so it uses a cache (it can also search data before the
columns.createdCell
callback is called as well!).You need to use orthogonal data, as described in the manual.
Regards,
Allan
Thank You Allan! That pointed me in the right direction.
So to show multiple values from the json data source in a single table cell I introduced a function in
columns.render
. It is important to usenull
as a data source for this column so all object parameters are available.},
Looks good to me
Allan