Git Product home page Git Product logo

Comments (8)

vincjo avatar vincjo commented on July 16, 2024

Hey
It will be effective on septembre i think
I have tout do some table header improvements first

from svelte-simple-datatables.

cuiqui avatar cuiqui commented on July 16, 2024

Hi! Is this on track by any chance?

from svelte-simple-datatables.

vincjo avatar vincjo commented on July 16, 2024

Hi,
I will start working on SSR support when "svelte-kit" is released I think

from svelte-simple-datatables.

hood avatar hood commented on July 16, 2024

I think times are mature enough to start working on server side pagination!

from svelte-simple-datatables.

RA9 avatar RA9 commented on July 16, 2024

@vincjo svelte-kit is in beta, can we expect a WIP on the server-side?

from svelte-simple-datatables.

samverrall avatar samverrall commented on July 16, 2024

Any updates on server-side support?

from svelte-simple-datatables.

stolinski avatar stolinski commented on July 16, 2024

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.

Hmerman6006 avatar Hmerman6006 commented on July 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.