-
Notifications
You must be signed in to change notification settings - Fork 17
How to integrate in your project
In order to use the KingTable library, there are two options:
- download the distribution files, contained in
/dist/
folder - download the source code, and work with ES6 source code It is also necessary to download the Open Iconic fonts.
When using the .css files inside the repository dist folder, the file kingtable.css contains all themes; but it is recommended to optimize your solution, by using the file: kingtable.core.css, which includes only the basic "flatwhite" theme; and eventually add the specific .css files of the desired themes.
The KingTable library defines an interface for HTTP requests and expected responses, in order to provide pagination and search out of the box. When performing AJAX calls to fetch data that requires server side pagination (and therefore, server side sorting and searching), it sends the information:
{
"page": [number], // page number
"size": [number], // results per page
"sortBy": [Array], // array describing sort criteria
"search": [string], // text search
"timestamp": [timestamp] // the timestamp of the first time the table was rendered
}
Example:
{
"page": 1,
"size": 30,
"sortBy": [ // name asc, color desc, red asc
[
"name", // first property in sort criteria
1 // 1 for ascending, -1 for descending
],
[
"color", // second property in sort criteria
-1 // 1 for ascending, -1 for descending
],
[
"red", // third property in sort criteria
1 // 1 for ascending, -1 for descending
]
],
"search": null,
"timestamp": "2017-04-29T19:08:36.800Z"
}
When receiving an AJAX response, it expects the following structure, if results are paginated server side:
{
items: [array], // array of items that respect the given filters (set of paginated results)
total: [number] // the total count of items that respect the given filters, except pagination
}
If, instead, a collection is meant to be small and to not grow over time and doesn't require server side pagination, then the server may return an array of items. Please refer to the working modes page, for more information about the previous sentence.