vuejs3 data tables select

vuejs3 data tables select

slycoderrslycoderr 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>

Answers

  • allanallan Posts: 63,517Questions: 1Answers: 10,473 Site admin

    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

  • slycoderrslycoderr Posts: 2Questions: 1Answers: 0

    Ok, that will be very helpful.

Sign In or Register to comment.