Pagination using vanilla JS
ydennisy opened this issue · comments
Hello!
What would you suggest the best way would be to add pagination to a HTML table which your library creates?
Most libs I can find use jQuery, I would like to avoid adding this as a dependency.
Thank you.
Dennis
Pagination is really outside the scope of what this library is meant to do. But to answer your question I would say you would have two options here
a) Request JSON data from your server for a specific page and render it into an HTML using a transform; then when a user asks for another page go back to the server to request for the new JSON data and then re-render it into an HTML table
b) Request for all the JSON data, then us javascript to break that into pages and implement logic ( you can do this using jquery events within the transform http://www.json2html.com/docs/#main-attributes-events) to paginate and re-render the table whenever a new page is selected.
Either way you'll need to re-render the new table using json2html with the new page data.