Commit 75803add585bfcf03cfa177b2bed357322e93bc6
1 parent
eec3859c
fixed scoll bar
Showing
3 changed files
with
81 additions
and
9 deletions
Show diff stats
examples/routers/table.vue
| ... | ... | @@ -9,6 +9,8 @@ |
| 9 | 9 | <br><br><br><br><br> |
| 10 | 10 | <Table border :columns="columns6" :data="data5"></Table> |
| 11 | 11 | <br><br><br><br><br> |
| 12 | + <Table border :columns="columns7" height="240" :data="data7"></Table> | |
| 13 | + <br><br><br><br><br> | |
| 12 | 14 | </div> |
| 13 | 15 | </template> |
| 14 | 16 | <script> |
| ... | ... | @@ -103,19 +105,19 @@ |
| 103 | 105 | } |
| 104 | 106 | ] |
| 105 | 107 | }, |
| 108 | + // { | |
| 109 | + // title: 'Gender', | |
| 110 | + // key: 'gender', | |
| 111 | + // align: 'center', | |
| 112 | + // width: 200, | |
| 113 | + // fixed: 'right' | |
| 114 | + // }, | |
| 106 | 115 | { |
| 107 | 116 | title: 'Gender', |
| 108 | 117 | key: 'gender', |
| 109 | 118 | align: 'center', |
| 110 | 119 | width: 200, |
| 111 | - fixed: 'right' | |
| 112 | - }, | |
| 113 | - { | |
| 114 | - title: 'Gender', | |
| 115 | - key: 'gender', | |
| 116 | - align: 'center', | |
| 117 | - width: 200, | |
| 118 | - fixed: 'right' | |
| 120 | + //fixed: 'right' | |
| 119 | 121 | } |
| 120 | 122 | ], |
| 121 | 123 | columns2: [ |
| ... | ... | @@ -342,6 +344,55 @@ |
| 342 | 344 | } |
| 343 | 345 | } |
| 344 | 346 | ], |
| 347 | + | |
| 348 | + columns7: [ | |
| 349 | + { | |
| 350 | + title: 'Date', | |
| 351 | + key: 'date', | |
| 352 | + sortable: true, | |
| 353 | + width:200, | |
| 354 | + }, | |
| 355 | + { | |
| 356 | + title: 'Name', | |
| 357 | + key: 'name', | |
| 358 | + width:200, | |
| 359 | + }, | |
| 360 | + { | |
| 361 | + title: 'Age', | |
| 362 | + key: 'age', | |
| 363 | + }, | |
| 364 | + { | |
| 365 | + title: 'Address', | |
| 366 | + key: 'address', | |
| 367 | + width:200, | |
| 368 | + } | |
| 369 | + ], | |
| 370 | + data7: [ | |
| 371 | + { | |
| 372 | + name: 'John Brown', | |
| 373 | + age: 18, | |
| 374 | + address: 'New York No. 1 Lake Park', | |
| 375 | + date: '2016-10-03' | |
| 376 | + }, | |
| 377 | + { | |
| 378 | + name: 'Jim Green', | |
| 379 | + age: 24, | |
| 380 | + address: 'London No. 1 Lake Park', | |
| 381 | + date: '2016-10-01' | |
| 382 | + }, | |
| 383 | + { | |
| 384 | + name: 'Joe Black', | |
| 385 | + age: 30, | |
| 386 | + address: 'Sydney No. 1 Lake Park Sydney No. 1 Lake Park', | |
| 387 | + date: '2016-10-02' | |
| 388 | + }, | |
| 389 | + { | |
| 390 | + name: 'Jon Snow', | |
| 391 | + age: 26, | |
| 392 | + address: 'Ottawa No. 2 Lake Park Ottawa No. 2 Lake Park Ottawa No. 2 Lake Park', | |
| 393 | + date: '2016-10-04' | |
| 394 | + } | |
| 395 | + ], | |
| 345 | 396 | } |
| 346 | 397 | }, |
| 347 | 398 | mounted () { | ... | ... |
src/components/table/table-head.vue
| ... | ... | @@ -61,7 +61,7 @@ |
| 61 | 61 | </div> |
| 62 | 62 | </th> |
| 63 | 63 | |
| 64 | - <th v-if="$parent.showVerticalScrollBar" :rowspan="headRows.length"></th> | |
| 64 | + <th v-if="$parent.showVerticalScrollBar && rowIndex===0" :class='scrollBarCellClass()' :rowspan="headRows.length"></th> | |
| 65 | 65 | </tr> |
| 66 | 66 | </thead> |
| 67 | 67 | </table> |
| ... | ... | @@ -131,6 +131,23 @@ |
| 131 | 131 | } |
| 132 | 132 | ]; |
| 133 | 133 | }, |
| 134 | + scrollBarCellClass(){ | |
| 135 | + let hasRightFixed = false; | |
| 136 | + for(var i in this.headRows){ | |
| 137 | + for(var j in this.headRows[i]){ | |
| 138 | + if(this.headRows[i][j].fixed === 'right') { | |
| 139 | + hasRightFixed=true; | |
| 140 | + break; | |
| 141 | + } | |
| 142 | + if(hasRightFixed) break; | |
| 143 | + } | |
| 144 | + } | |
| 145 | + return [ | |
| 146 | + { | |
| 147 | + [`${this.prefixCls}-hidden`]: hasRightFixed | |
| 148 | + } | |
| 149 | + ]; | |
| 150 | + }, | |
| 134 | 151 | itemClasses (column, item) { |
| 135 | 152 | return [ |
| 136 | 153 | `${this.prefixCls}-filter-select-item`, | ... | ... |
src/components/table/table.vue