vuejs3 data tables select
vuejs3 data tables select
slycoderr
Posts: 2Questions: 1Answers: 0
I have this:
<template>
<DataTable ref="table" :columns="columns" :data="data" :options="{select: true}" class="table table-hover table-striped">
</DataTable>
</template>
Right now, in order to get to the selected event and selected row I have to do this:
mounted(){
this.$refs.table.dt()
.on( 'select', function ( e, dt, type, indexes ) {
var rowData = dt.rows( indexes ).data().toArray();
console.log(rowData);
} )
},
but in this event callback, I can't access my data or props. how can I use the vuejs @select event on the DataTable tag so I can define my own method in my component like below?
methods:{
onSelect(e, dt, type, indexes ){
var rowData = dt.rows( indexes ).data().toArray();
console.log(rowData);
}
}
<DataTable ref="table" :columns="columns" :data="data" :options="{select: true}" class="table table-hover table-striped" @select="onSelect">
</DataTable>
This discussion has been closed.
Answers
In theory, this PR should add such events, but I'm having some problems with it at the moment. Should be able to get it resolved soon and published as a new version.
Allan
Ok, that will be very helpful.