ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Using Wordpress? Get our lightening fast Wordpress Optimised Hosting from £1.60 / month

View Plans

How To Create Powerful Datatables in WordPress

Table, table, table. Tables are pretty everywhere, in all sites in the web. My guess is that 99.999% of websites have some form of a table. From those beautiful menus you admire to those football league standings. Some websites even use tables to list their content in a grid-like manner. Mmmh, think ecommerce products. Tables allow us to present data in rows and columns. At the intersection of a row and a column is a cell. Cells can show a variety of data types like text, links and images. It’s even possible to show lists of data in a table cell. Heck, we can even nest tables, show a full table in a given table cell. Clearly that shows how powerful and flexible they are. They allow us easily present 2D data, rows and columns.

What You'll get in this lesson.

At the end of this lesson you'll be able to create a table that:

  • Is responsive.
  • Can be filtered/searched and sorted.
  • Can import from or export data to CSV,HTML,Excel or JSON file.
  • Supports various data types.
  • Can be embedded into posts,pages and widgets via shortcode.
  • Supports Pagination etc.

We can have a simple HTML table or a responsive table. Anybody can easily create a simple HTML table. For instance look at the below code snippet.

<!DOCTYPE html>
<html>
<head>
<style>
 th, td {
    border: 1px solid green;
}
</style>
</head>
<body>

<table> <tr> <th>FullName</th> <th>Country</th> <th>Age</th> <th>Position</th> <th>Strength</th> <th>Jersey</th> </tr> <tr> <td>David De Gea</td> <td>Spain</td> <td>26</td> <td>Goalkeeper</td> <td>Sharp Reflex</td> <td>1</td> </tr> <tr> <td>Anthony Martial</td> <td>France</td> <td>21</td> <td>Striker</td> <td>Pace/Dribbling</td> <td>11</td> </tr> <tr> <td>Ander Herera</td> <td>Spain</td> <td>28</td> <td>Midfielder</td> <td>Work Rate</td> <td>12</td> </tr> <tr> <td>Marcus Rashford</td> <td>England</td> <td>19</td> <td>Striker</td> <td>Pace/Dribbling</td> <td>19</td> </tr> <tr> <td>Juan Manuel Mata</td> <td>Spain</td> <td>29</td> <td>Midfielder</td> <td>Intelligence</td> <td>8</td> </tr> <tr> <td>Michael Carrick</td> <td>England</td> <td>35</td> <td>Midfielder</td> <td>Passing Range/Positioning</td> <td>26</td> </tr> </table>

</body> </html>

The code snippet can give us this simple table: Simple HTML Table

Not so pretty isn’t it? The aesthetics part can be improved with a bit of CSS. However, more important is that it's not responsive. It cannot adjust appropriately to a device’s screen resolution. This can lead to some data not being visible to the user. That’s bad. We should then use a responsive table. Responsive tables can ‘respond’ to the device’s width and height. This is important especially in this world that's infiltrated with devices of all resolutions.

This then brings us to Tablepress. It's one of the best wordpress table plugins out there. It enables us create and manage some powerful datatables.

Advantages of Tablepress.

There are perhaps dozens of wordpress table plugins out there. Why then have we decided to use Tablepress over others. Well, because:

  1. It’s easy to install, configure and use.
  2. It’s free.
  3. It's feature rich. Sortable, Filterable, Importing, Exporting, Editing, Pagination etc.
  4. It's highly customizable. We can easily change the look and feel of our table via CSS. We can also enable or disable javascript. Nobody is forcing us with all the features, we can enable or disable them depending on our needs.
  5. Regular updates. No wonder it has been rated 5-stars by almost 3000 folks.

So what next? Well, remember we said it’s a wordpress plugin. Let’s proceed to installation. My assumption is you have a working wordpress installation. It can either be hosted locally or remotely.

Installation

  1. Head over to the wordpress plugins directory. Type ‘Tablepress’ and hit enter. This requires internet connection.
  2. Click ‘Install Now’ button to install our plugin.
  3. Click ‘Activate’ to activate the plugin after installation.
Tablepress Installation

Well, our plugin is installed, let’s proceed to the configuration page.

Creating A New Table

Given that our plugin is installed, let’s create a new table.

  1. A Tablepress menu has been added to your wordpress dashboard menu. Click the ‘Add New Table’ menu item.
  2. In our ‘new table’ form, type the table name and an optional description. The table names will identify specific tables as we can create multiple tables. Add New Table

  3. Choose the number of rows and columns.

  4. Hit ‘Add Table’ button.
  5. Well our beautiful table is created in seconds. Now go ahead and type some data.

Table Preview

Options: - You can choose to make the first row be the row header, just as I have done.

Editing Table Data

  • We can edit our new table. Let’s add some data.
  • Make sure you click 'save' to save the data.
  • We can also preview the table. Note that when you preview, some features requiring JavaScript like sorting, filtering and pagination may not work. However, once we have added the shortcode to our page and published they should work.
Edit Table Data

Table Options

  • You can set table options like whether to use first row as header and last row as footer.
  • You can also set whether to alternate row background colors.
  • If you have a custom CSS class you can include as well.
Table Options

Manipulating the Table

There are various options for manipulating the table to your liking: - Insert links and images by clicking the indicated buttons. - You can also use advanced editor similar to one you normally use when editing posts. This means for instance that you can insert advanced data like code and images into table cell. First make sure you select the cell by checking both its row and column, then you click advanced editor button. - You can hide or show a given a row or column. Don’t forget to select it first. - You can duplicate rows or columns. You can also insert and delete rows and columns. - You can also add rows and columns in bulk. - You can combine cells as well. See the options below.

Table Manipulation Options

Datatable Features

Datatables.net is a very popular jQuery library among web developers. It allows us to easily make responsive tables with features like Sorting, Filtering and Pagination. Tablepress makes use of datatable to provide these features out of the box. However, given it is JavaScript, it’s optional. If you prefer a simple html table you can disable these features. In the settings options we can choose to:

  • Enable or Disable Datatable completely.
  • Enable or Disable Sorting, Filtering and Pagination only.
  • Determine the number or rows per single page. You can allow the user/visitor to change the number of rows visible. This is a good practice as it gives users control over the amount of information they are comfortable taking in at a given moment.
Datatable Features

Including Table in a post/page

You can easily include a table created by tablepress in a post or page. This is easy: - Copy the shortcode of the table. - Paste it in the post/page editor. Make sure to choose the Text tab in your editor before pasting. If you paste it in the Visual tab, in some cases it can be formatted further, hence treated as a simple text. - Publish your post/page.

This is what we get:

final DataTable

Take note of the following:

  • We can sort data by any column.
  • We can search/filter our data.
  • Our table is automatically paged. Users can choose page size.

Duplicating Tables

Tablepress allows us to duplicate tables too. Just click the ‘Copy Table’ button to duplicate a table.

Exporting Tables

Tablepress provides a feature to export table into CSV, HTML and JSON formats. - In the menu, choose ‘Export Table’ menu item. - Choose the table you would want to export. - Select the Export format: CSV, HTML and JSON. - Choose whether it should be zipped. - Hit ‘Download Export File’ button. Exporting Table

Importing Tables

It’s also possible to import data from a CSV, HTML, JSON and Excel file into a table built by tablepress. This is very powerful because we can easily input a lot of useful data into our table and show it in our site. For example, you can import football league standings, student results or some sales records. A huge time saver indeed.

Even better, we can import from different sources. Be it via File Upload, URL, File on server or even manually. You can then import into a new table, append into an existing table or even replace an existing table. You make sure you choose the import format. Importing table

Conclusion

I look at a plugin like Tablepress and am not surprised that it’s one of the most popular plugins out there. It’s very easy to use and very powerful. It meets most of our needs with regards to a table. It’s very customizable. I can easily, for instance, disable some of the features I don’t need and just create a basic html table. On the other hand, it allows me to easily make use of features like sorting, filtering and pagination without getting my hands full of grease. I can even give the user the capability to define his/her page size. The fact that I can not only type my data but also import makes it quite useful. Think those boring sales reports that you have to somehow feed into a webapp from excel. Besides, I can import directly from a URL. Think those football league results from some JSON data source. The tables it generate are beautiful too. However, you can also use you custom CSS classes. Tablepress is simply easy to use, flexible and powerful. It can meet most of our needs. Let’s therefore be creative and and make some beautiful tables.

Using Wordpress? Get our lightening fast Wordpress Optimised Hosting from £1.60 / month

View Plans