Getting ALL rows to submit
Getting ALL rows to submit
dreadedmanraz
Posts: 24Questions: 5Answers: 0
I have a datatable that I am using to display a large number of records. I am also using the table to update values for the collection.
However, when I Postback the page, I am only receiving the data for the visible pages.
I believe that Datatables removes the non-visible rows from the DOM.
How can I get the values for all of the rows in all of the pages (i.e. the dom to contain all pages)?
This discussion has been closed.
Answers
Use the
rows().nodes()
method or$()
method. Example.Allan
Thanks for that.
This is my code:
So how do I get it to post to the DOM without wrecking the paging on the next load?
The
draw()
option has the option to keep the paging where it currently is by passingfalse
in as the first parameter. See thedraw()
documentation.Allan
This still has the same problem.
The paging on the next load does the same thing, showing 10 but displaying all.
Can you link to the page and code that has this issue so we can debug it please. Using
.draw( false )
should work.Allan
I think I found the issue. If stateSave: true, then when the page reloads, it remembers that the paging was disabled.
So is there a way I can make it post the whole collection of data, but still have stateSave: true?
Can you link to the page please? I don't really understand the issue at the moment. It might be that you are using server-side processing in which case only the visible rows exist.
Allan
I can't link to the code as it is a secured system. I am not using Server-side processing.
I've just tried to reproduce this error here.
Steps:
paging: false
andstateSave: true
. All rows shown.I'm afraid I would need a test case showing the issue to be able to understand and help address what is going wrong.
Thanks,
Allan
I don't know how to do form submits on the live datatables.
The page needs to load with paging = true as I want the paging to work.
I'll explain the process:
Here is the problem, on step 5, I want to load the page with paging on so only some rows are shown. So the paging only goes off to submit the data to the server.
So this is my original question:
How do I get it to post ALL DATA to the DOM without wrecking the paging on the next page load?
I'm only guessing, since I don't have a test case I can look at, but do you have state saving enabled? If so, then the page length of -1 will be saved. If that is not the case, then I would need a test case as I noted before.
Allan
Yes I do have statesaved enabled. Is there a way around this to get it to work as I need?
I would suggest trying to avoid showing all rows to be honest. Could you use an option like this: http://datatables.net/examples/api/form.html .
Allan
I'm only showing all rows so I can post the data
The example I gave above shows how you can Ajax submit the whole form without showing all rows.
However, if you want to do a full page reload submit, then what you could do is move all input elements out from the table at submit time and simply into the form.
The final alternative is to use
stateSaveParams
and set a flag when you submit the form that your state save parameters callback will check for and not save the -1 length option (replacing it with 10 for example).Allan