Simple Table
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).
Click to checkout the new features
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 option 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.
By setting the responsiveLayout option to true, the table will automatically hide/show columns to prevent the columns from exceeding the width of container.
If you resize the the width of the window you will see the number of columns change to ensure the data fits with the table. This option can be combined with fitColumns to make a table that gracefully responds to all display widths.
By creating groups in the column definition array, you can create multi line headers with groups of columns.
You can use the colVertAlign option to set how the text in your columns headers should be vertically aligned.
You can use the frozen property in a columns definition object to freeze that column in place during horizontal scrollling.
It is possible to convert a standard HTML Table element into a tabulator, pulling all the data directly from the table into the tabulator when it is created.
If you want to pull the column headers in from the table, you need to make sure that you have defiend a thead element with each column header in a th element. If you specify the width attribute on a header, then this will be set as the width of the column in the tabulator.
You can set any of the standard Tabulator options when you create your table this way, so can easily convert old tables to take advantage of the many features Tabulator has to offer.
Name | Age | Gender | Height | Favourite Color | Date of Birth |
---|---|---|---|---|---|
Billy Bob | 12 | male | 1 | red | 22/04/1994 |
Mary May | 1 | female | 2 | blue | 14/05/1982 |
Name | Age | Gender | Height | Favourite Color | Date of Birth |
---|---|---|---|---|---|
Billy Bob | 12 | male | 1 | red | 22/04/1994 |
Mary May | 1 | female | 2 | blue | 14/05/1982 |
Using the editable setting on each column, you can make a user editable table.
Any time a cell is edited it triggers the cellEdited 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
If you are looking for a non grid based format to your table then you can use a row formatter to create custom row layouts.
You can use the rowFormatter callback to replace the contents of the row with any layout you like. In this example we will create a simple table in each row containing and image and some vertically centered text properties.
When replacing the entire contents of the row it is important to include only one column in your column definition array to ensure the table renders correctly. It is also advisable to enable fitColumns and disabled colResizable options.
You can use external JavaScript libraries in any of your formatters. In this example we will use the popular sparklines.js library.
We will be passing an array of values into a field and then using a custom formatter to turn this array into a sparkline.
The Sparklines library can be downloaded from Git Hub.
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:
By settting the headerFilter parameter for a column you can add column based filtering directly into your table.
See the documentation for Header Filtering for more information.
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).
Using the selectable option, you can allow users to select rows in the table via a number of different routes:
Tablulator allows you to add new rows, delete existing rows 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 allows you to download the table data as a file directly from your browser, no server needed.
The download will contain the text values of all data currently visible in the table, matching the current column layout, column titles, sorting and filtering.
You can localize the content of your tables to meet the needs of your regional users. Any number of language options can be configured for column headers and pagination controls.
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 here.
A LESS file is also provided, containing a set of variables to make generating your own theme even easier. This can be found in tabulator.less
Tabulator comes with a number of packaged themes in the /themes directory of the package. To use one of these simply include the matching css file instead of the default tabulator.css
A plain, simplistic layout showing only basic grid lines. This can be found in /themes/tabulator_simple.css
A dark, stylish layout using simple shades of grey. This can be found in /themes/tabulator_midnight.css
A neat, stylish layout using one primary color. This color can be set in the @primary variable in the /themes/tabulator_modern.less file to alter the style to match your colour scheme. This can be found in /themes/tabulator_modern.css
A colorful, bright layout using shades of orange and brown. This can be found in /themes/tabulator_autumn.css
Match Tabulator to the standard Bootstrap theme /themes/bootstrap/tabulator_bootstrap.css
Match Tabulator to the standard Semantic UI theme /themes/semantic-ui/tabulator_semantic-ui.css
You can override the default tabulator styling in document, or simply edit the provided tabulator.css file to make your own custom theme.