I can get the table working with server side data and server side search, but when I start trying to add pagination and sorting on top of that (both server side) I get errors and it stops working.
I've looked into Grid.js's docs and, while there are some examples for server side search, pagination and sorting, there's no example when you want to get them working together. I fail to realize how to get them all working at the same time.
Here's a code snippet, I'm using it inside a Sveltekit application.
<script>
import Grid from 'gridjs-svelte';
import { page } from '$app/stores';
const columns = [
{
name: 'Nombres',
sort: true
},
{
name: 'Apellido',
sort:true
}
];
const search = {
enabled: true,
server: {
url: (prev, keyword) => `${prev}?search=${keyword}`
}
};
const pagination = {
limit: 5,
server: {
url: (prev, page, limit) => `${prev}?limit=${limit}&offset=${page * limit}`
}
}
</script>
<Grid
{columns}
sort
{search}
{pagination}
server={{
url: 'https://mytestingdomain.com/afiliado/find?page=0&size=500&sort=apellido,asc',
headers:{
'Authorization': 'Bearer thisiswherethetokengoes',
'Content-Type': 'application/json' },
then: (data) =>
data.content.map((afiliado) => {
return [afiliado.nombres, afiliado.apellido];
})
}}
/>
<style global>
@import 'https://cdn.jsdelivr.net/npm/gridjs/dist/theme/mermaid.min.css';
</style>
Thanks in advance for taking the time to read and/or help!