How To Refresh Datatables Sort And Filter Info
For simplicity of the example I have a DataTable which I load from HTML. This DataTable is having parts of its content updated through jQuery BUT the updated content while visible
Solution 1:
This is the correct way:
$(document).ready(function() {
var dt = $('#example').DataTable({});
dt.cell( $("#entry2_votes") ).data(60) ;
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkhref="https://cdn.datatables.net/1.10.15/css/jquery.dataTables.min.css"rel="stylesheet"/><scriptsrc="https://cdn.datatables.net/1.10.15/js/jquery.dataTables.min.js"></script><tableid="example"class="display"width="100%"cellspacing="0"><thead><tr><th>First name</th><th>Last name</th><th>Votes</th><th>Location</th></tr></thead><tbody><tr><th>John</th><th>Doe</th><thid="entry1_votes">50</th><th>London</th></tr><tr><th>Hill</th><th>Vaught</th><thid="entry2_votes">120</th><th>Berlin</th></tr><tr><th>Charles</th><th>Roy</th><thid="entry3_votes">78</th><th>Liege</th></tr></tbody></table>
Fiddle: https://jsfiddle.net/HappyiPhone/d97bpqvs/7/
Solution 2:
You have to reinitialize data table after updating with jquery or you can update by datatable in-built methods/api
$('#example').DataTable().destroy();
$('#example').DataTable().draw();
Post a Comment for "How To Refresh Datatables Sort And Filter Info"