forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableContent.vue
More file actions
65 lines (63 loc) · 1.45 KB
/
TableContent.vue
File metadata and controls
65 lines (63 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<template>
<table class="q-table horizontal-separator" :style="tableStyle">
<colgroup>
<col v-if="selection" style="width: 45px;" />
<col v-for="col in cols" :style="{width: col.width}" />
<col v-if="head && scroll.horiz" :style="{width: scroll.horiz}" />
</colgroup>
<thead v-if="head">
<tr>
<th v-if="selection"> </th>
<th
v-for="col in cols"
:class="{sortable: col.sort}"
@click="sort(col)"
>
<sort-icon
v-if="col.sort"
:field="col.field"
:sorting="sorting"
></sort-icon>
<span v-html="col.label"></span>
<q-tooltip v-if="col.label" v-html="col.label"></q-tooltip>
</th>
<th v-if="head && scroll.horiz"></th>
</tr>
</thead>
<tbody v-else>
<slot></slot>
</tbody>
</table>
</template>
<script>
import SortIcon from './plugins/sort/SortIcon.vue'
import { QTooltip } from '../tooltip'
export default {
name: 'q-table-content',
components: {
SortIcon,
QTooltip
},
props: {
cols: Array,
head: Boolean,
sorting: Object,
scroll: Object,
selection: [String, Boolean]
},
computed: {
tableStyle () {
return {
width: this.head && this.vert ? `calc(100% - ${this.scroll.vert})` : '100%'
}
}
},
methods: {
sort (col) {
if (col.sort) {
this.$emit('sort', col)
}
}
}
}
</script>