Created
August 19, 2020 14:42
-
-
Save cmitz/3145374a5b885b02bacf80394209e210 to your computer and use it in GitHub Desktop.
Bug Demo: vue-tables-2 selectable row with uniqueKey option
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<v-client-table | |
name="myTable" | |
:data="tableData" | |
:columns="tableColumns" | |
:options="tableOptions" | |
@select="updateSelectedItems" | |
/> | |
<hr /> | |
<h4>Selected Items</h4> | |
<ul class="my-list"> | |
<li v-for="item in selectedItems" :key="item.id"> | |
{{item.name}} | |
</li> | |
</ul> | |
</div> | |
</template> | |
<script> | |
import Vue from 'vue'; | |
import { ClientTable } from 'vue-tables-2'; | |
Vue.use(ClientTable, {}); | |
const tableData = [{ | |
other_id: 1, | |
name: 'broccoli', | |
color: 'green' | |
}, { | |
other_id: 6, | |
name: 'pumpkin', | |
color: 'orange' | |
}, { | |
other_id: 7, | |
name: 'carrot', | |
color: 'orange' | |
}, | |
] | |
const tableColumns = [ 'id', 'name', 'color' ] | |
const tableOptions = { | |
uniqueKey: 'other_id', | |
selectable: { mode: 'multiple' }, | |
customFilters: [{ | |
name: 'fruitsByColorFilter', | |
callback: (row, query) => row.color === query, | |
}], | |
initFilters: { | |
'fruitsByColorFilter': 'orange' | |
} | |
} | |
export default { | |
name: "MyTable", | |
data() { | |
return { | |
selectedItems: [], | |
tableData, | |
tableColumns, | |
tableOptions | |
} | |
}, | |
methods: { | |
updateSelectedItems(selectedItemsArray) { | |
this.selectedItems = selectedItemsArray; | |
}, | |
}, | |
} | |
</script> | |
<style scoped> | |
.my-list { | |
width: 200px; | |
text-align: start; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment