I have a table working with jQuery DataTables and pagination
I have over 300 registrys which 50 are the max on each page. Every time I change from page to page the other 250 registrys are removed from DOM so when I submit and do the POST to my controller I only get a list of 50 models which are the ones on my current page.
How do I access the other 250, or tell the table to send them all? I have searched and I have read that this is the normal behavior of pagination. But how do you guys work around it?
CAUSE
When using DataTables plug-in with pagination only current page rows exist in the DOM for performance and compatibility. Therefore when you submit the form, only current page form controls values are being submitted.
SOLUTION 1: Submit form directly
The trick is to turn form elements from pages other than current into
<input type="hidden">
before submitting the form.See jQuery DataTables: How to submit all pages form data - Submit directly for more details and examples.
SOLUTION 2: Submit form via Ajax
Another solution is to submit the form via Ajax.
See jQuery DataTables: How to submit all pages form data - Submit via Ajax for more details and examples.
NOTES
Please note that both solutions will work in client-side processing mode only.
LINKS
See jQuery DataTables: How to submit all pages form data for more details.