Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

How to use VDataTable? #2

Open
linuxing3 opened this issue Jan 30, 2019 · 4 comments
Open

How to use VDataTable? #2

linuxing3 opened this issue Jan 30, 2019 · 4 comments
Labels
question Further information is requested

Comments

@linuxing3
Copy link

linuxing3 commented Jan 30, 2019

In VDataTable, how to show data in table body with slots? Any examples?

            <VDataTable items={mockItems} headers={mockHeaders}>
              <tr slot={"mockHeaders"} scopedSlots={{ props: (props)=> ... }} >
              </tr>
            </VDataTable>

How the slots works?
Thanks!

@Shinigami92
Copy link
Contributor

After a little bit of trying... I got something to work

<VDataTable headers={this.headers} items={this.items} class="elevation-1"
  scopedSlots={{
    items: (props: { item: MyTest }) => (
      <tr>
        <td>{props.item.id}</td>
        <td>{props.item.name}</td>
      </tr>
    )
  }}
/>

With this, I have full typescript power over my item.id and item.name.

But currently scopedSlots is underlined and says that headerCell, headers and pageText are missing. But I already have defined them in <VDataTable headers={this.headers}.... It is working... So I think headerCell, headers and pageText should be optional instead of required.

@Shinigami92
Copy link
Contributor

I got Pagination worked in this way:

// ...
pagination={this.pagination}
on={{
  'update:pagination': (pagination: VDataTablePagination): void => {
    this.pagination = pagination;
  }
}}
// ...

This is equivalent to :pagination.sync

(VDataTablePagination are my own definition)

@chanlito chanlito added the question Further information is requested label Jun 9, 2019
@Shinigami92
Copy link
Contributor

I created an example of VDataTable: https://github.com/Shinigami92/vuetify-tsx/blob/example/data-tabe/src/examples/tables/DataTableExample1.tsx
But it is broken and shows no items :/

Console says:

Error in render: "ReferenceError: h is not defined"
vue.runtime.esm.js?2b0e:1888 ReferenceError: h is not defined

@Shinigami92
Copy link
Contributor

Now that we have an example, I think we can close this Issue 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants