No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    using table row @click event not working

    Help
    5
    6
    7890
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J
      jeimz173 last edited by

      Hi i am trying to add some @click event on every table rows of my data table please help me.
      here is what i did:

      <template slot="body" slot-scope="props" :props="props" class="cursor-pointer" @click.native="alert('test not working')">
                <q-tr :props="props" >
                  <q-td auto-width>
                    <q-checkbox color="primary" v-model="props.selected" />
                  </q-td>
                  <q-td key="vehicle" :props="props">
                    <q-checkbox color="primary" v-model="props.expand" checked-icon="remove" unchecked-icon="add" class="q-mr-md" />
                    {{ props.row.vehicle.plateNumber }}
                  </q-td>
                  <q-td key="dispatcher" :props="props">{{ props.row.dispatcher.name }}</q-td>
                  <q-td key="client" :props="props">{{ props.row.client.name }}</q-td>
                  <q-td key="origin" :props="props">{{ props.row.origin.name +' ( '+ props.row.origin.code + ')' }}</q-td>
                  <q-td key="destination" :props="props">{{ props.row.destination.name +' ( '+ props.row.destination.code + ')' }}</q-td>
                  <q-td key="created_at" :props="props">{{ props.row.created_at }}</q-td>
                </q-tr>
                <q-tr v-show="props.expand" :props="props">
                  <q-td colspan="100%">
                    <div class="container">
                    </div>
                  </q-td>
                </q-tr>
              </template>
      

      thank you in advance!

      1 Reply Last reply Reply Quote 0
      • J
        jeimz173 last edited by

        whoops! i fixed it thank you!

        this what i did 🙂

        <template slot="body" slot-scope="props" :props="props">
                  <q-tr :props="props" class="cursor-pointer" @click.native="$router.push({ path: '/user/trips', query: { tripId: props.row._id } })">
        
        1 Reply Last reply Reply Quote 3
        • J
          Joshua last edited by

          To whomever else is researching this question,

          https://github.com/quasarframework/quasar/commit/b7396aa296e0c83bdfb8d192464a2fe5457d7049

          As of v1.2.6 you can add a @row-click to q-table.

          D 1 Reply Last reply Reply Quote 2
          • D
            danilowm @Joshua last edited by

            @Joshua Thank You!!

            Example:

            <q-table
              title="TITLE"
              :data="data"
              :columns="columns"
              row-key="name"
              @row-click="onRowClick"
            
            methods: {
                onRowClick (evt, row) {
                  console.log('clicked on', evt, row)
                }
              }
            
            1 Reply Last reply Reply Quote 1
            • A
              AlisonSandrade last edited by

              The q-table @row-click method worked for me, however, I found a problem with the event when using a q-btn-dropdown on the same line.

              If you use a q-btn-dropdown on the clicked line the @row-click event is triggered when the button is clicked and if you place an @row-click.prevent the q-btn-dropdown works correctly, but the @row-click event loses the expected behavior and no longer brings the object of the clicked line.

              Any solution?

              metalsadman 1 Reply Last reply Reply Quote 0
              • metalsadman
                metalsadman @AlisonSandrade last edited by

                @AlisonSandrade it’s not the row-click that you prevent, it’s the q-btndropdown’s @click event ie. @click.stop.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post