Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
79
rated 0 times [  85] [ 6]  / answers: 1 / hits: 31367  / 8 Years ago, wed, february 3, 2016, 12:00:00

I have a Datatable that uses static data from an HTML file.



Using either the columnDefs data function, or the columnDefs render function, I can perform some output adjustment - blanking out some of the TD's based on their content, and their position on the currently displayed page (without altering the data source).



However, when a user changes the number of displayed rows, I then need to reset & redo my adjustments on the data, as different cells will now need blanking, and previously blanked entries may need showing again.



So, what I want to do is in the length.dt event (number of display rows just changed), call something that causes the Datatable to either re-render the entire table, or re-load the entire data (which would thereby call my columnDefs render or columnDefs data functions)



Is this possible? Or is my approach flawed and I need to find another way?


More From » jquery

 Answers
50

Use rows().invalidate() to invalidate data for all rows and draw() to redraw the table.



Please note that 'data' in rows().invalidate('data') is required if you use Javascript data structure (with data or columns.render options).



$('#your_table').DataTable()
.rows().invalidate('data')
.draw(false);

[#63462] Monday, February 1, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dasias

Total Points: 344
Total Questions: 100
Total Answers: 100

Location: Hong Kong
Member since Tue, Oct 19, 2021
3 Years ago
;