Comments (8)
Hey
It will be effective on septembre i think
I have tout do some table header improvements first
from svelte-simple-datatables.
Hi! Is this on track by any chance?
from svelte-simple-datatables.
Hi,
I will start working on SSR support when "svelte-kit" is released I think
from svelte-simple-datatables.
I think times are mature enough to start working on server side pagination!
from svelte-simple-datatables.
@vincjo svelte-kit
is in beta, can we expect a WIP
on the server-side?
from svelte-simple-datatables.
Any updates on server-side support?
from svelte-simple-datatables.
I just forked and loaded up the master branch and it seems to work pretty well with Svelte Kit / SSR already. Looks like the master branch isn't the same build that's published, so if you are looking to use this with Svelte Kit and SSR, you probably can just by loading it up locally from the master branch.
from svelte-simple-datatables.
Good day, I setup a project using Svelte and imported svelte-simple-datatables
with axios
to try and use server side rendering: given the revolutionary syntax of Svelte and the inbuilt Reactive declaration I thought it would be as simple as declaring a function that promises to update a variable and re-drawing
the datatable on each search
or refresh
or some event in the life cycle
of a component. But it seems I am implementing something incorrectly since I can see my variable being updated from server side but not the datatable:
<script>
import { onMount } from "svelte";
import { Datatable } from 'svelte-simple-datatables';
import {env} from './utils/EnvUtils.js';
import axios from "axios";
console.log(env);
const BASE_URL = env.host + 'records';
const config = {
headers: {
"X-Requested-With": "XMLHttpRequest",
"Accept": "application/json",
'Content-Type': 'application/json',
"X-CSRF-Token": document.querySelector('meta[name="csrf-token"][content]').content
}
}
const settings = {
sortable: true,
pagination: true,
scrollY: true,
rowsPerPage: 50,
columnFilter: false,
css: true,
labels: {
search: 'Search...', // search input placeholer
filter: 'Filter', // filter inputs placeholder
noRows: 'No entries to found',
info: 'Showing {start} to {end} of {rows} entries',
previous: 'Previous',
next: 'Next',
},
blocks: {
searchInput: true,
paginationButtons: true,
paginationRowCount: true,
}
}
let rows;
let rowData;
let currentPage = 1;
let search;
$: updateData(currentPage, search); // re-runs if page or search changes
let perPage = 10;
async function fetchData(page, search = undefined) {
console.log(page);
try {
const getUrl = (search!==undefined) ? `${BASE_URL}?page=${page}&per_page=${perPage}&search=${search}&delay=1` : `${BASE_URL}?page=${page}&per_page=${perPage}&delay=1`;
const response = await axios.get(getUrl, config);
const { data } = await response;
console.log("data:", data);
return data && data['data']!==null && data['data']!==undefined ? data.data : [];
} catch (error) {
console.error("Error: ", error);
}
}
async function updateData(page, search = undefined) {
rowData = await fetchData(page, search);
console.log("row data:", rowData); // this gets updated
}
// onMount(updateData);
</script>
<Datatable {rowData} {settings} bind:dataRows={rows} id={'record-datatable'}>
<thead>
<!-- <th data-key="id">ID</th> -->
<th data-key="title">Title</th>
<th data-key="updated_at">Updated</th>
</thead>
<tbody>
{#if rows}
{#each $rows as row}
<tr>
<!-- <td>{row.id}</td> -->
<td>{row.title}</td>
<td>{row.updated_at}</td>
</tr>
{/each}
{/if}
</tbody>
</Datatable>
Am I doing something wrong or is this impossible?
Edit
Okay I found my error: the data
and settings
attributes of the Datatable
component was omitted, after adding it; the datatable updated.
from svelte-simple-datatables.
Related Issues (20)
- Initial datatable mount doesn't show x-axis scroll bar if table size larger than datatable container.
- Table version 3.29.7 filter & search function doesn't work. HOT 1
- Sticky header cell width not same as original table header cell width. HOT 4
- Demo site is down HOT 8
- Width for individual columns HOT 1
- Width Issue
- 500 Error on SvelteKit: `Cannot read property 'length' of undefined` HOT 6
- Using data directly from a store HOT 2
- Initital sort HOT 2
- <thead> element for sorting columns is invalid HTML
- Quick questions
- Table rerender infinitely with non-zero padding for left and right HOT 1
- Redraw function doesn't work correct on window width reducing
- Disabling scrollY also disable columnFilters
- Filter function does not have access to global/outer scope HOT 1
- define which columns to search with search field (not column-filters)
- Extended the PaginationRowCountHTML.svelte to show pagesTotal etc
- Unable to apply styles to component
- Add Select/Option or any HTML Input below thead for filtering
- Save filters and reuse them HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-simple-datatables.