Normally it takes lot of time to build tables using HTML and JQuery , with the help of JQuery datatable plugin we can easily build tables and add additional functionalities such as sorting, search , pagination and also exporting table content in to different format’s
Installing dependencies :
These files perform basic operations, like search , pagination, sorting etc…, to get additional functionalities you need to add additional plugins
Next, you need to assign items collection to the data object of datatable in the document.ready function and also you can define columns and buttons for data table, the buttons are export buttons, when you click on any button it will read the array object and export into the respective format
/********************************** Keys and Strokes **************************************/
dataType:"json"//set to JSON
Now, open your page in browser, it should look something like below, without any export buttons
Now, after refreshing page, you can see export buttons ( refer below screen shot )
To apply styles for buttons use below classes
/* vertical-align: middle; */
/* -webkit-user-select: none; */
Finally, the page appears something like below when you click on excel button it should export content into excel format
No related posts.
A technology enthusiast and a professional blogger from India. Through out my IT career, I have had the pleasure of working on various new technologies and built products like www.ziprides.com and some other products. Unfortunately, my attempts have not given me the desired results and as a result, I have finally decided to build a professional blog where I would like to share all my learnings and hoping to learn from other enthusiasts around the world.