An easy to use table generation JQuery UI Plugin
Tabulator allows you to create a table with in seconds from any JSON formatted data.
It relies on no external css or images, simply include the library in your JQuery UI project and you're away!
Tabulator is packed with useful features including:
In its simplest form, all you need to set in the options are the column titles and field names.
By default columns are resizable (using edge of column header) and sortable (as strings).
Tables will automatically resize to fit the data
By setting the fitColumns to true, the table will resize columns so that they fit perfectly inside the width of the container.
If a width is specified on any columns, where possible the columns will be set at this width and other columns will be resized around them. If there is not enough space to fit all the columns in, then all column widths are ignored and they are sized equally.
It is possible to turn a standard HTML Table element into a tabulator, pulling all the data directly from the table into the tabulator when it is created.
Name | Age | Gender | Height | Favourite Color | Date of Birth | Likes Cheese |
---|---|---|---|---|---|---|
Oli Bob | 12 | male | 1 | red | 1 | |
Mary May | 1 | female | 2 | blue | 14/05/1982 | true |
Using the editable setting on each column, you can make a user editable table.
Any time a cell is edited it triggers the rowEdit callback, to allow you to process any changes.
You can call the getData method to get an array of all of the tables data, including any edits
Sorting is enabled by default, and can be toggled on or off by column using the sortable option.
By default all columns are sorted as text, different sort functions can be set using the sorter option
You can define a custom sorter functions in the sorter option if you need bespoke sorting functionality.
You can programmatically trigger a sort using the sort function.
Tabulator allows you to format your data in a wide variety of ways, so your tables can display information in a more graphical and clear layout.
you can set formatters on a per column basis using the formatter option in the column data.
Tabulator comes with a number of preconfigured formatters including:
You can define a custom formatter function in the formatter option if you need more bespoke formatter functionality
You can create icon/button columns, by not specifying a field parameter in the column data and creating a custom formatter for the column contents. In the example below we have created a print button on the left of each row.
You can also set a row formatter using the rowFormatter option, this allows you to format the styling of the row as a whole
You can group rows together using the groupBy option. To group by a field, set this option to the name of the field.
To group by more complex operations you should pass a function that returns a string that represents the group.
Tabulator allows you to filter the table data by any field in the data set.
To set a filter you need to call the setFilter method, passing the field you wish to filter, the comparison type and the value to filter for
Tabulator comes with a number of filter comparison types including:
Tabulator allows you to paginate your data. simply set the pagination property to true.
If you have set the height of the table then the data will be automatically paginated to fit within the table.
If you wish to define how many rows should be shown on a page, set this in the paginationSize property. If you set the paginationSize without setting the height, the Tabulator will automatically resize to fit the data
Tabulator can store the layout of columns in a cookie so that each time a user comes back to the page the table is laid out just as they left it.
Try resizing (drag the right edge of a column header) or rearranging (drag the middle of a column header) the columns of this table, then refresh the page. your new layout will persist.
Data can be loaded into the table from a remote URL using a JSON formatted string.
If you always request the same URL for your data then you can set it in the ajaxURL option when you create your Tabulator
Click the button below to load sample data via AJAX (you will need PHP enabled on your webserver for this to work).
Tablulator allows you to add new rows and columns, delete existing rows and columns, and clear all table data with ease.
Using the movableRows parameter you can allow the user to move rows around the table using the handle on the left-hand side of the row.
Tabulator features a range of callbacks to allow you to handle user interaction.
Tabulator is styled using a full set of CSS classes, making theming of the table very simple, A full list of these can be found in the GitHub readme.md file