rubanraj54 / vue-bootstrap4-table

Advanced table based on Vue 2 and Bootstrap 4 ⚡️
MIT License
219 stars 57 forks source link

Get Selection #38

Closed soongsta closed 5 years ago

soongsta commented 5 years ago

Hi There

Is there a way to access the selected rows in (for example) the onDownload

onDownload(payload) { //process selected items console.log(payload.items) }

Or do we track the selected items through a local array?

rubanraj54 commented 5 years ago

HI @soongsta

Currently, it doesn't support sending selected items in the payload.

But it is a valid request, so I will consider implementing this in my next release.

Cheers, Ruby.

rubanraj54 commented 5 years ago

Hi @soongsta

Now you can get the "selectedItems" array along with the action buttons event payload.

onDownload(payload) {
//process selected items
console.log(payload.selectedItems)
}

There is another way to access the selected row's data directly (Note: But this is not a right approach, still in this case you can use it)

Example:

Set a ref name to the table component.

<div id="app">
  <vue-bootstrap4-table ref="myvuetable" :rows="rows" :columns="columns" :actions="actions" :config="config" @on-download="onDownload" >
  </vue-bootstrap4-table>
</div>

And in your code, you can access the selected_items directly as shown below.

this.$refs.myvuetable.selected_items

Also, I made an example codepen for you https://codepen.io/rubanraj54/pen/MRmvzb .

Cheers, Ruby.