Tabulator-基于jQuery UI的实用表格插件 A table generation JQuery UI Plugin

Tabulator

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:

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).

Fit To Data

Tables will automatically resize to fit the data

Fit To Width

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.

Editable Data

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

Sorters

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.

Formatters

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.

Filter Data

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:

Filter Parameters

AJAX Data Loading

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).

Add / Delete Rows

Tablulator allows you to add new rows, delete existing rows and cleat all table data with ease.

Callbacks

Tabulator features a range of callbacks to allow you to handle user interaction.

Theming

Tabulator has a range of additional options to help customise your table. A full list of these can be found in the GitHub readme.md file