Searching for dynamic content

Searching for dynamic content

yifanLuyifanLu Posts: 2Questions: 1Answers: 0

I've created a column of cells using this render function:

render: function(data, type, row, meta) {
    return '<span class="hide">'+data+'</span>'+
           '<input class="field-table-input" type="text" value='+data+'>';
},

So the cell information can be entered in the cell, and the span's value is updated by this function,

$input.change(function() {
    $span = $(this).siblings('span');
    $span.text($(this).val());
}

However, when I'm using the search bar, it will catch only the initial value, not any value that has been changed through the input, is there a way to search for dynamically changed input?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,971Questions: 1Answers: 10,160 Site admin
    Answer ✓

    The issue is that DataTables will search its cache of search data, rather than making requests to the DOM to get search information (which would be a serious performance hit).

    What you would need to do is invalidate DataTables' cache for the row using row().invalidate().

    Allan

  • yifanLuyifanLu Posts: 2Questions: 1Answers: 0

    Thank you for point the difference out. I was working around it by creating an additional column solely for searching that I could update with cell().data(), but it was feeling pretty hacky.

This discussion has been closed.