theme_datatable($variables)for rendering tables programmatically.
- Download and install DataTables and Views module.
- Download the DataTables plugin from their download page (1.9+).
- Extract the file directly into the DataTables module. The path to the plugin should be s
Views IntegrationNow that we have everything setup, let's go into Views and create a table.
Steps1. Go to Structure -> Views (admin/structure/views) and click on the "Add new view" link.
2. Fill in the "Add new view" form with the values and click on "Continue & Edit" button.
- Add a few fields to the table. For this tutorial, I'll add the Node Id, Title and Type field.
- Click on the Full link in the Pager section and change the paper to "Display all items".
- We need to turn off the Views pager because DataTables implements its own pager.
- Save the view by clicking the Save button in the top right corner.
- Go to
/datatableto test out the view. If everything is working, you should see a table with pagination and a search filter.
6. Check the Sortable checkboxes for all the columns so you can sort each column.
7. Once you have finished configuring the table, scroll to the bottom and click on the "Apply (all displays)" button, and then save the view.
8. Refresh the views page, and now you should be able to sort by each column.
This is a simple use case if you want to learn more, go to the settings section and play around with some of the other options.