[SOLVED] Detect cell or value click in table?



  • I have poured over the table docs here (https://quasar.dev/vue-components/table) but have been unable to figure out how to detect when a cell (or that cell’s value) has been clicked (so that I can trigger a method with that value).

    I tried a value format with the following, but it outputs my source text in the cell instead of rendering it:

    format: (val, row) => `<span class="link" @click="setSearch(${val})">${val}</span>`
    

    Can anyone point me in the right direction? Thanks!



  • Ok, I figured it out. I needed to create a template slot and then format that:

    <template v-slot:body-cell-myVal="props">
           <q-td key="myVal" :props="props">
                <span class="link" @click="setSearch(props.row.myVal)">{{ props.row.myVal }}</span>
           </q-td>
    </template>
    

Log in to reply