Skip to content

Commit 309c332

Browse files
author
pablohpsilva
committed
fixed header and footer
1 parent 9970988 commit 309c332

File tree

2 files changed

+35
-3
lines changed

2 files changed

+35
-3
lines changed

docs/src/pages/components/Table.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,8 +523,8 @@
523523
</md-button>
524524
</md-table-alternate-header>
525525

526-
<md-table md-sort="calories">
527-
<md-table-header>
526+
<md-table md-sort="calories" mdFixedHeader>
527+
<md-table-header slot="header">
528528
<md-table-row>
529529
<md-table-head md-sort-by="dessert">Dessert (100g serving)</md-table-head>
530530
<md-table-head md-sort-by="type" width="100px">Type</md-table-head>

src/components/mdTable/mdTable.vue

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1-
<template>
1+
<!--<template>
22
<div class="md-table" :class="[themeClass]">
33
<table>
44
<slot></slot>
55
</table>
66
</div>
7+
</template>-->
8+
<template>
9+
<div class="md-table" :class="[themeClass]">
10+
<div v-if="mdFixedHeader">
11+
<table class="md-table-fixed-header" style="box-shadow: 0px 3px 5px 0px rgba(0,0,0,0.08);">
12+
<slot name="header"></slot>
13+
</table>
14+
</div>
15+
<div :style="bodyStyle" class="md-table" :class="[themeClass]">
16+
<table>
17+
<slot v-if="!mdFixedHeader" name="header"></slot>
18+
<slot></slot>
19+
<slot v-if="!mdFixedFooter" name="footer"></slot>
20+
</table>
21+
</div>
22+
<div v-if="mdFixedFooter">
23+
<table>
24+
<slot name="footer"></slot>
25+
</table>
26+
</div>
27+
</div>
728
</template>
829

30+
931
<style lang="scss" src="./mdTable.scss"></style>
1032

1133
<script>
@@ -15,6 +37,8 @@
1537
export default {
1638
name: 'md-table',
1739
props: {
40+
mdFixedHeader: Boolean,
41+
mdFixedFooter: Boolean,
1842
mdSortType: String,
1943
mdSort: String
2044
},
@@ -30,6 +54,14 @@
3054
selectedRows: {}
3155
};
3256
},
57+
computed: {
58+
bodyStyle() {
59+
return {
60+
overflow: 'auto',
61+
height: this.height
62+
};
63+
}
64+
},
3365
methods: {
3466
emitSort(name) {
3567
this.sortBy = name;

0 commit comments

Comments
 (0)