v0.17 Server-side support
Server-side support
Thanks to the amazing @blerrgh for his work on server-side support for core plugins such as addSortBy, addColumnFilters, addTableFilter, and addPagination!
Server-side support allows you to handle data manipulation on your server instead of on the browser. When enabled on a plugin, it will not have any effect on the table rows. Instead, it will treat the existing data as though it has already been modified on the server but continue to update its own state. This lets you use Svelte Headless Table as a state manager for your server.
Usage
Simply pass serverSide: true when instantiating a plugin to enable server-side data manipulation.
const data = writable([...]);
const table = createTable(data, {
sort: addSortBy({ serverSide: true }),
filter: addTableFilter({ serverSide: true }),
page: addPagination({ serverSide: true }),
});
const columns = table.createColumns(...);
const {rows, pluginStates} = table.createViewModel(columns);
const {sortKeys} = pluginStates.sort;
const {filterValue} = pluginStates.filter;
const {pageSize, pageIndex} = pluginStates.filter;
async function updateQuery() {
const q = new URLSearchParams();
q.set('order_by', $sortKeys[0].id);
q.set('order_dir', $sortKeys[0].order);
q.set('filter', $filterValue);
q.set('limit', String($pageSize));
q.set('skip', String($pageSize * $pageIndex));
$data = await fetch(`/api_endpoint?${q});
}
// ...What's Changed
Full Changelog: v0.16.2...v0.17.0