vincjo / datatables

A toolkit for creating datatable components with Svelte
https://vincjo.fr/datatables
MIT License
372 stars 15 forks source link

Remote search and pagination #19

Closed thelinuxlich closed 1 year ago

thelinuxlich commented 1 year ago

An example would be awesome!

vincjo commented 1 year ago

Base component :

<script>
    import { DataHandler } from '@vincjo/datatables'
    import { myJSON } from 'somewhere'
    import RemoteSearch from './RemoteSearch.svelte'
    import RemotePagination from './RemotePagination.svelte'

    const handler = new DataHandler(myJSON, { rowsPerPage: 10 })
</script>

<RemoteSearch {handler}/>

<RemotePagination {handler}/>

RemoteSearch.svelte :

<script>
    export let handler
    let value = ''
</script>

<input type="text" bind:value on:input={() => handler.search(value)} />

RemotePagination.svelte : DataHandler getters return derived stores that update according pagination state.

<script>
    export let handler
    const pageNumber = handler.getPageNumber()
    const pages = handler.getPages({ ellipsis: true }) 
</script>

<button on:click={() => handler.setPage('previous')}>
    Previous
</button>

{#each $pages as page}
    <button type="button"
        class:active={$pageNumber === page}
        on:click={() => handler.setPage(page)}
    >
        {page ?? '...'}
    </button>
{/each}

<button type="button" on:click={() => handler.setPage('next')}>
    Next
</button>
thelinuxlich commented 1 year ago

Hmm I don't understand how you're demonstrating a remote data fetch. Ideally, we should pass a option to DataHandler constructor which accepts the URL, and receives the search/filter, sort and page parameters

vincjo commented 1 year ago

I did'nt understand your request. This lib only handles client-side interactions with data. No opinion on the data fetching part

I saw this repo recently, which seems to focus on server-side processing https://github.com/Parazeya/svelte-flextable

maybe you will find more answers there

thelinuxlich commented 1 year ago

Hmm interesting, why this project looks so similar to yours?

vincjo commented 1 year ago

I guess it extends mine ? idk The author clearly started from my code base, including for the documentation site …

thelinuxlich commented 1 year ago

Exactly! So weird not giving the credit...

riziles commented 1 year ago

This seems to cross a pretty bright ethical line if not a legal one. I'm happy to post an issue in their repo to at least acknowledge you if nothing else.

vincjo commented 1 year ago

You're right, I'll get in touch to clear this up

riziles commented 1 year ago

@vincjo Looks like he/she/they have acknowledged you. What are your thoughts on it?

vincjo commented 1 year ago

Hello @riziles I was able to contact the author, who immediately agreed to add the credits. Personally I have no problem with reusing/copying code from this lib. Credits are highly appreciated but not required (unless the documentation site is exactly the same)

I won't be able to respond positively to all feature requests (especially edge cases) to keep things as simple as possible. That's why I have no problem with other developers taking over this project for their needs

riziles commented 1 year ago

Cool. I appreciate that.