GithubHelp home page GithubHelp logo

Comments (3)

bryanmylee avatar bryanmylee commented on May 18, 2024

Could you try something like this?

<script lang="ts">
  import VirtualList from 'svelte-tiny-virtual-list';
  import {createTable} from 'svelte-headless-table';

  const table = createTable();
  const columns = table.createColumns(...);
  const {rows} = table.createViewModel(columns);
</script>

<table>
  <thead>...</thead>
  <!-- use the virtual list component as `tbody` -->
  <!-- we can PR `asChild` or `as` support for `svelte-tiny-virtual-list` -->
  <VirtualList
    width="100%"
    height={600}
    itemCount={$rows.length}
    itemSize={50}>
    <svelte:fragment slot="item" let:index let:style>
      {@const row = $rows[index]}
      <Subscribe rowAttrs={row.attrs()}>
        <tr {style} {...rowAttrs}>
          {#each row.cells as cell (cell.id)}
            <Subscribe attrs={cell.attrs()} let:attrs>
              <td {...attrs}>
                <Render of={cell.render()} />
              </td>
            </Subscribe>
          {/each}
        </tr>
      </Subscribe>
    </svelte:fragment>
  </VirtualList>
</table>

from svelte-headless-table.

FluffyDiscord avatar FluffyDiscord commented on May 18, 2024

Not really, since the package adds two DOM elements to manage it's list, thus breaking the header columns (not aligned)

image

from svelte-headless-table.

bryanmylee avatar bryanmylee commented on May 18, 2024

@FluffyDiscord Full disclaimer, I've never used svelte-tiny-virtual-list before but it's probably there to provide the overflow behaviour. Looking at it's code, it provides slots for the header and footer so you could try:

<script lang="ts">
  import VirtualList from 'svelte-tiny-virtual-list';
  import {createTable} from 'svelte-headless-table';

  const table = createTable();
  const columns = table.createColumns(...);
  const {rows} = table.createViewModel(columns);
</script>

<!-- use the virtual list component as `table` -->
<!-- we can PR `asChild` or `as` support for `svelte-tiny-virtual-list` -->
<VirtualList
  width="100%"
  height={600}
  itemCount={$rows.length}
  itemSize={50}>
  <thead slot="header">...</thead>
  <svelte:fragment slot="item" let:index let:style>
    {@const row = $rows[index]}
    <Subscribe rowAttrs={row.attrs()}>
      <tr {style} {...rowAttrs}>
        {#each row.cells as cell (cell.id)}
          <Subscribe attrs={cell.attrs()} let:attrs>
            <td {...attrs}>
              <Render of={cell.render()} />
            </td>
          </Subscribe>
        {/each}
      </tr>
    </Subscribe>
  </svelte:fragment>
</VirtualList>

from svelte-headless-table.

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.