add a event @on-select-cancel to Table. #705

This commit is contained in:
Rijn 2017-07-07 13:01:49 -05:00
parent e4767e5a90
commit b0f1c61f8e
2 changed files with 13 additions and 4 deletions

View file

@ -1,5 +1,5 @@
<template> <template>
<Table border :columns="columns5" :data="data5"></Table> <Table border :columns="columns5" :data="data5" @on-select="onSelect(true)" @on-select-cancel="onSelect(false)"></Table>
</template> </template>
<script> <script>
import etable from '../components/table.vue'; import etable from '../components/table.vue';
@ -8,6 +8,11 @@
data () { data () {
return { return {
columns5: [ columns5: [
{
type: 'selection',
width: 60,
align: 'center'
},
{ {
type: 'expand', type: 'expand',
render: (h) => { render: (h) => {
@ -73,6 +78,12 @@
}, },
] ]
} }
},
methods: {
onSelect (value) {
window.alert(value);
}
} }
} }
</script> </script>

View file

@ -404,9 +404,7 @@
this.objData[_index]._isChecked = status; this.objData[_index]._isChecked = status;
const selection = this.getSelection(); const selection = this.getSelection();
if (status) { this.$emit(status ? 'on-select' : 'on-select-cancel', selection, JSON.parse(JSON.stringify(this.data[_index])));
this.$emit('on-select', selection, JSON.parse(JSON.stringify(this.data[_index])));
}
this.$emit('on-selection-change', selection); this.$emit('on-selection-change', selection);
}, },
toggleExpand (_index) { toggleExpand (_index) {