@@ -8,6 +8,7 @@ export default {
8
8
default : ( ) => [ ]
9
9
} ,
10
10
11
+ border : [ Boolean ] ,
11
12
sort : { }
12
13
} ,
13
14
@@ -18,7 +19,7 @@ export default {
18
19
} ,
19
20
20
21
methods : {
21
- getColumnClass ( col ) {
22
+ getColumnClass ( col , index ) {
22
23
const cls = [ 'v2-table__cell' , 'v2-table__column-cell' ] ;
23
24
24
25
if ( col . sortable && ! col . type ) {
@@ -40,11 +41,7 @@ export default {
40
41
41
42
getColStyle ( col ) {
42
43
const style = { } ;
43
-
44
- style . width = ! isNaN ( parseInt ( col . width ) ) ? '90px' : `${ parseInt ( col . width , 10 ) } px` ;
45
- style . height = ! isNaN ( parseInt ( this . table . colHeight , 10 ) ) ? '40px' : `${ parseInt ( this . table . colHeight , 10 ) } px` ;
46
-
47
- // style.textAlign = ['left', 'center', 'right'].indexOf(col.align) > -1 ? col.align : 'center';
44
+ style . width = `${ col . $realWidth } px` ;
48
45
49
46
return style ;
50
47
} ,
@@ -60,40 +57,52 @@ export default {
60
57
61
58
render ( h ) {
62
59
return (
63
- < div class = 'v2-table__table-thead' >
64
- < div class = 'v2-table__header-row' >
60
+ < table
61
+ class = { { 'v2-table__header' : true , 'v2-table__border' : this . border , 'v2-table__header-border' : this . border } }
62
+ cellspacing = '0'
63
+ border = '0'
64
+ cellpadding = '0' >
65
+ < colgroup >
65
66
{
66
- this . columns . map ( ( column , index ) => {
67
- return (
68
- < div key = { index }
69
- onClick = { this . changeSortRule ( column ) }
70
- class = { this . getColumnClass ( column ) }
71
- style = { this . getColStyle ( column ) }
72
- >
73
- {
74
- typeof column . renderHeader === 'function'
75
- ? column . renderHeader . call ( this . _renderProxy , h , { column, index } )
76
- : column . label
77
- }
78
- {
79
- column . sortable && ! column . type
80
- ? < span class = 'v2-table__caret-wrapper' >
81
- < i class = 'v2-table__sort-caret ascending-caret' > </ i >
82
- < i class = 'v2-table__sort-caret descending-caret' > </ i >
83
- </ span >
84
- : ''
85
- }
86
- {
87
- column . type === 'selection'
88
- ? < check-box cur-row-index = { - 1 } > </ check-box >
89
- : ''
90
- }
91
- </ div >
92
- ) ;
93
- } )
67
+ this . columns . map ( column => < col style = { this . getColStyle ( column ) } /> )
94
68
}
95
- </ div >
96
- </ div >
69
+ </ colgroup >
70
+ < thead >
71
+ < tr >
72
+ {
73
+ this . columns . map ( ( column , index ) => {
74
+ return (
75
+ < th key = { index }
76
+ onClick = { this . changeSortRule ( column ) }
77
+ class = { this . getColumnClass ( column , index ) }
78
+ style = { { height : this . table . colHeight + 'px' } }
79
+ colspan = '1'
80
+ rowspan = '1' >
81
+ {
82
+ typeof column . renderHeader === 'function'
83
+ ? column . renderHeader . call ( this . _renderProxy , h , { column, index } )
84
+ : column . label
85
+ }
86
+ {
87
+ column . sortable && ! column . type
88
+ ? < span class = 'v2-table__caret-wrapper' >
89
+ < i class = 'v2-table__sort-caret ascending-caret' > </ i >
90
+ < i class = 'v2-table__sort-caret descending-caret' > </ i >
91
+ </ span >
92
+ : ''
93
+ }
94
+ {
95
+ column . type === 'selection'
96
+ ? < check-box cur-row-index = { - 1 } > </ check-box >
97
+ : ''
98
+ }
99
+ </ th >
100
+ ) ;
101
+ } )
102
+ }
103
+ </ tr >
104
+ </ thead >
105
+ </ table >
97
106
) ;
98
107
}
99
108
} ;
0 commit comments