Select rows in q-table via buttons using Vue.js
P粉384679266
2023-09-02 16:25:14
<p>When I press the edit button in the action button in <code>q-table</code> the button opens a modal. However, since the checkbox in <code>q-table</code> is not selectable, I get an error when I want to update the schema. What I want is when I click the action button, the table detects that I have selected the row. </p>
<p>My table:</p>
<pre class="brush:php;toolbar:false;"><template>
<q-table
title="Students"
:filter="filter"
:rows="studentsData"
:columns="columns"
row-key="id"
dense
selection="single"
class="puffy-shadow rounded q-pa-lg students-table"
v-model:selected="selectedStudentRow"
>
<template v-slot:body-cell-actions="props">
<q-td :props="props">
<q-btn class="action-btn" color="green" icon="mdi-pen" @click="openStudentDialog = true;">
</q-td>
</template>
</q-table>
<q-dialog v-model="addStudentNoteDialog" class="add-student-note-dialog">
<q-card>
<q-card-section>
<q-form>
<q-input v-model="note" label="Note" outlined></q-input>
<q-card-actions align="right">
<q-btn label="Cancel" color="primary"
@click="cancelNote">
</q-btn>
<q-btn label="Add Note" color="primary"
@click="addStudentNote(selectedStudentRow)">
</q-btn>
</q-card-actions>
</q-form>
</q-card-section>
</q-card>
</q-dialog>
</template>
<script>
export default {
name: "StudentsTable",
data(){
return{
openStudentDialog: false,
}
}
computed: {
selectedStudentRow: {
get() {
return this.$store.getters.selectedStudentRow;
},
set(val) {
this.$store.commit('selectedStudentRow', val);
}
}
},
</script></pre>
<p>When the button I want is clicked, the modal opens and the checkbox is checked in the table.What do I want to show in this image</p>
<p>I tried sending prop.row on button click event. But it doesn't work. </p>
Where do you "log" the data?
If I understand correctly, I would create something like:
Similar things