question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Q-table, @row-click not work within body-slot

See original GitHub issue

What happened?

see as title said if useing body-slot in q-table, the event @row-click never work…

What did you expect to happen?

Im tring to use body-slot manage user clicked row bgc/border color, cuz no api to set this prop. Thus, try to use body-slot :class=‘is_current_clicked_row’, however the api @row-click never worked.

Reproduction URL

https://codepen.io/pen?&editors=101

How to reproduce?

    <q-table
      title="Treats"
      :rows="rows"
      :columns="columns"
      row-key="name"
      @row-click="current_clicked_row" //here
    >
      <template v-slot:body="props">
        <q-tr :props="props">
           ........... see https://quasar.dev/vue-components/table#body-slots


  setup () {
      let current_clicked_row = (evt, row, index)=>{
        console.log(index); // no data in console...
      }
  
    return {
      current_clicked_row,
      columns,
      rows
    }
  }

Flavour

Quasar CLI (@quasar/cli | @quasar/app)

Areas

Components (quasar)

Platforms/Browsers

Chrome

Quasar info output

V2.5.5 + VUE3

Relevant log output

No response

Additional context

No response

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
metalsadmancommented, Feb 14, 2022

You need to add @click event to your q-tr.

this method only returns PointerClick event, not row or index. @row-click is still not working for q-tr or q-table while using a body-slot.

Screen Shot 2022-02-14 at 9 10 20 AM

follow what Milos suggested.

0reactions
superuser-chicommented, Jun 10, 2022

Hi @gowy222,

Make sure your data has a unique id and specify it in your q-table using the row-key prop

Read more comments on GitHub >

github_iconTop Results From Across the Web

using table row @click event not working - Quasar forum
Hi i am trying to add some @click event on every table rows of my data table please help me. here is what...
Read more >
jQuery table row click not working - Stack Overflow
I was checking a few sites, and I came up with the below: <table class="admin_table"> <thead> < ...
Read more >
Table | Quasar Framework
The QTable Vue component allows you to display data in a tabular manner and it's packed with a lot of related features. It's...
Read more >
How to get a slot when a row of a QTableWidget is clicked
Hi! I need a way in which where the user clicks a whole row (not only a cell) I can execute a function....
Read more >
Quasar QTable 'body-cell-name' slot is not recognized
This issue relates to https://youtrack.jetbrains.com/issue/WEB-52117. The IDE does not recognize the slot name as shown in the screenshot: image.png.
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