How to check/uncheck all checkboxes with pagination
How to check/uncheck all checkboxes with pagination
Hello, i'am working on a very old project using datatables version 1.8.1. So i'am wondering how can i check/uncheck all checkboxes which are on multiple page. I'am using ajax-source to rendering the table and the bServerSide is set to true.
$('form table input[name="check_all"]').on('change', function() { $(this).closest('table').find('input[type="checkbox"]:not(:disabled)').prop('checked', $(this).prop('checked')); });
This code help me to select all checkbox on the current page only. What i want is to select all checkboxes.
I found the code below on the forum but its shows an error that dt.rows() is not a function maybe due to version difference ?
dt.rows().nodes().to$().find
Thanks in advance for your help,
This discussion has been closed.
Answers
It would be worthwhile updating to the most recent version as 1.8 is very old now! Would that be possible?
Colin
@colin I agree with you but since it is a very old project, we are not planning to update plugins for the moment. is there any solution without updating data-tables? Thanks.
With server side processing the only table data available at the client are the rows being shown on the page. There is nothing built-in to keep track of checkboxes with server side processing. You will need to keep track of the checkboxes yourself. I'm not familiar with the DT 1.8 API's but here are a couple ideas:
select-allcheckbox and use your code above to check all on the page for display.Kevin
Hi, I just found in legacy documentation that there is a equivalence of
dt.rows().nodes()=>fnGetNodes(), i've also found that we could usefnGetHiddenNodes()for invisible checkboxes (off-screen) but i do not know if there is an equivalence offnGetHiddenNodes()for DT1.8. Also, i am looking for an equivalence forto$()ortoJQuery()in the same version.Finaly i succeed by adapting my code to code of this page of Dt. I have made that all checkbox is chosen by default in my controller and stock the unchecked box's id into an array and when i reload the page, i check if the id of checkboxes is included in this array, if so, it will uncheck the checkbox.
Thanks a lot for your helps.