Examples: Table with Selection using body-slots

See original GitHub issue

Currently, I`m working on a project and I need a table that needs Multiple Selection and use of the BodySlots at the same time.

I tried different approaches but I end with this image

Then its my question and request for an example on the docs of table with selection and using body-slots, since I didnt found a way to fill the first column with checkbox in the right way. Maybe it`s a doubt of others and can be an improvement in the docs.

My Thanks to Quasar Team!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

8reactions
danielalejandromatheuscommented, Mar 24, 2020

I had the same problem a while ago, but don’t fear, the props in the body slot provide you a way to select the row!

On your v-slot:body do this:

<template v-slot:body="props">
<q-tr :props="props" @click="props.selected = true">
        <q-td>
          <q-checkbox v-model="props.selected" color="primary" />
        </q-td>
        <q-td v-for="col in props.cols" :key="col.name" :props="props">{{
          col.value
        }}</q-td>
      </q-tr>
</template>

What I did there is to enable the selection by either clicking on the entire QRow OR the QCheckbox, the props.selected property iis a boolean that indicates whether the row is selected or not. as you can see, you can bind it to a checkbox since they output booleans. It’s stated in the QTable API documentation for the body slot, although there’s no examples for it.

Cheers, Daniel.

4reactions
rstoenescucommented, Mar 25, 2020

Thank you @hitostacha for providing the answer. I’d like to see that from more in the community, because this allows us to focus on more features.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Table | Quasar Framework
QTable is a component that allows you to display data in a tabular manner. It's generally called a datatable. It packs the following...
Read more >
Tree: Default header and body slots - Quasar Playground
https://quasar.dev/vue-components/tree#Example--Default-header-and-body-slots ... Good table presentation. This is some default content.
Read more >
Should I use :columns in a q-table when using slots?
Yes because columns is used for the table header. See this example: https://quasar.dev/vue-components/table#Body-slots.
Read more >
How to highlight rows in v-data-table on click in Vuetify ...
I want to have rows marked as "readed" (so css bold/not-bold) after these rows were clicked. Problem: I already found some examples here...
Read more >
Web search results - body slot table
Examples : Table with Selection using body-slots #6675 · https://github.com/quasarframework/quasar/issues/6675 · Here is my code. Table: Body slot: When I ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found