Checkbox Table

카탈로그
  1. 1. Checkbox Table
    1. 1.1. Configuration
      1. 1.1.1. Example
    2. 1.2. Selected row action slot
      1. 1.2.1. Example

Checkbox Table

One of the most common customizations in datatables is selectable rows. Creating a checkbox table with vue-good-table is easier than ever.

Configuration

type: Object

Object containing select options

1
2
3
4
5
6
7
8
9
10
11
12
<vue-good-table
@on-selected-rows-change="selectionChanged"
:columns="columns"
:rows="rows"
:selectOptions="{
enabled: true,
selectOnCheckboxOnly: true, // only select when checkbox is clicked instead of the row
selectionInfoClass: 'custom-class',
selectionText: 'rows selected',
clearSelectionText: 'clear',
disableSelectInfo: true, // disable the select info panel on top
}">

Although, the on-selected-rows-change event should be enough for you to keep track of selected rows. If at any time you need to know what rows are selected, you can get it via ref.

1
this.$refs['my-table'].selectedRows;

Example

1
2
3
4
5
6
7
<vue-good-table
@on-selected-rows-change="selectionChanged"
:columns="columns"
:rows="rows"
:select-options="{ enabled: true }"
:search-options="{ enabled: true }">
</vue-good-table>

Selected row action slot

Once you select a row, an info bar shows up. This bar allows for a customizable slot for your action buttons.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
<vue-good-table
@on-selected-rows-change="selectionChanged"
:columns="columns"
:rows="rows"
:select-options="{
enabled: true,
}"
:search-options="{ enabled: true }">
<div slot="selected-row-actions">
<button>Action 1</button>
</div>
</vue-good-table>
<!-- click on a row below to show the action button -->

::: tip Note
You can style the selection info bar by supplying a css class to selectionInfoClass property.
:::