moappi / json2html

Json2html is a lightning fast client side javascript HTML templating library with wrappers for both jQuery and Node.js.

Home Page:https://www.json2html.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.