|
@@ -104,6 +104,56 @@
|
|
|
address: 'No. 189, Grove St, Los Angeles',
|
|
|
zip: 'CA 90036'
|
|
|
}],
|
|
|
+ tableData4: [{
|
|
|
+ date: '2016-05-03',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-02',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-04',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-01',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-08',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-06',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-07',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }],
|
|
|
currentRow: null,
|
|
|
multipleSelection: []
|
|
|
};
|
|
@@ -144,6 +194,10 @@
|
|
|
return 'positive-row';
|
|
|
}
|
|
|
return '';
|
|
|
+ },
|
|
|
+
|
|
|
+ deleteRow(index, rows) {
|
|
|
+ rows.splice(index, 1);
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -155,7 +209,7 @@
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-## Table
|
|
|
+## Table
|
|
|
|
|
|
Display multiple data with similar format. You can sort, filter, compare your data in a table.
|
|
|
|
|
@@ -471,7 +525,7 @@ When there are too many rows, you can use a fixed header.
|
|
|
```
|
|
|
:::
|
|
|
|
|
|
-### Table with fixed column
|
|
|
+### Table with fixed column
|
|
|
|
|
|
When there are too many columns, you can fix some of them.
|
|
|
|
|
@@ -576,7 +630,7 @@ When there are too many columns, you can fix some of them.
|
|
|
```
|
|
|
:::
|
|
|
|
|
|
-### Table with fixed columns and header
|
|
|
+### Table with fixed columns and header
|
|
|
|
|
|
When you have huge chunks of data to put in a table, you can fix the header and columns at the same time.
|
|
|
|
|
@@ -683,6 +737,133 @@ When you have huge chunks of data to put in a table, you can fix the header and
|
|
|
```
|
|
|
:::
|
|
|
|
|
|
+### Fluid-height Table with fixed header (and columns)
|
|
|
+
|
|
|
+When the the data is dynamically changed, you might want the table to have a maximum height rather than a fixed height and to show the scroll bar if needed.
|
|
|
+
|
|
|
+:::demo By setting the attribute `max-height` of `el-table`, you can fix the table header. The table body scrolls only if the height of the rows exceeds the max height value.
|
|
|
+```html
|
|
|
+<template>
|
|
|
+ <el-table
|
|
|
+ :data="tableData4"
|
|
|
+ border
|
|
|
+ style="width: 100%"
|
|
|
+ max-height="250">
|
|
|
+ <el-table-column
|
|
|
+ fixed
|
|
|
+ prop="date"
|
|
|
+ label="Date"
|
|
|
+ width="150">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="name"
|
|
|
+ label="Name"
|
|
|
+ width="120">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="state"
|
|
|
+ label="State"
|
|
|
+ width="120">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="city"
|
|
|
+ label="City"
|
|
|
+ width="120">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="address"
|
|
|
+ label="Address"
|
|
|
+ width="300">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ prop="zip"
|
|
|
+ label="Zip"
|
|
|
+ width="120">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ inline-template
|
|
|
+ :context="_self"
|
|
|
+ fixed="right"
|
|
|
+ label="Operations"
|
|
|
+ width="120">
|
|
|
+ <span>
|
|
|
+ <el-button
|
|
|
+ @click.native.prevent="deleteRow($index, tableData4)"
|
|
|
+ type="text"
|
|
|
+ size="small">
|
|
|
+ Remove
|
|
|
+ </el-button>
|
|
|
+ </span>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ methods: {
|
|
|
+ deleteRow(index, rows) {
|
|
|
+ rows.splice(index, 1);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData4: [{
|
|
|
+ date: '2016-05-03',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-02',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-04',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-01',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-08',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-06',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-07',
|
|
|
+ name: 'Tom',
|
|
|
+ state: 'California',
|
|
|
+ city: 'Los Angeles',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles',
|
|
|
+ zip: 'CA 90036'
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+```
|
|
|
+:::
|
|
|
+
|
|
|
### Grouping table head
|
|
|
|
|
|
When the data structure is complex, you can use group header to show the data hierarchy.
|
|
@@ -875,7 +1056,7 @@ You can also select multiple rows.
|
|
|
@selection-change="handleSelectionChange">
|
|
|
<el-table-column
|
|
|
type="selection"
|
|
|
- width="50">
|
|
|
+ width="55">
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
inline-template
|
|
@@ -1086,7 +1267,7 @@ Filter the table to find desired data.
|
|
|
:::
|
|
|
|
|
|
### Custom column template
|
|
|
-
|
|
|
+
|
|
|
Customize table column so it can be integrated with other components.
|
|
|
:::demo Activate custom column template by adding the `inline-template` attribute. By default, the context of `el-table-column` is the one where `el-table` lies, and you can customize it with the `context` attribute, e.g. `:context="_self"` refers to the current context. This is useful when sometimes Table is encapsulated into another component, and `table-column` is distributed by slots. In `el-column`, you have access to the following data: row, column, $index and store (state management of Table).
|
|
|
```html
|
|
@@ -1111,7 +1292,7 @@ Customize table column so it can be integrated with other components.
|
|
|
<el-popover trigger="hover" placement="top">
|
|
|
<p>Name: {{ row.name }}</p>
|
|
|
<p>Addr: {{ row.address }}</p>
|
|
|
- <div slot="reference">
|
|
|
+ <div slot="reference" class="name-wrapper">
|
|
|
<el-tag>{{ row.name }}</el-tag>
|
|
|
</div>
|
|
|
</el-popover>
|
|
@@ -1177,7 +1358,8 @@ Customize table column so it can be integrated with other components.
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
|
|
| data | table data | array | — | — |
|
|
|
-| height | Table's height. By default it has an auto height. If its value is a number, the height is measured in pixels; if its value is a string, the height is affected by external styles | string/number | — | — |
|
|
|
+| height | Table's height. By default it has an `auto` height. If its value is a number, the height is measured in pixels; if its value is a string, the height is affected by external styles | string/number | — | — |
|
|
|
+| maxHeight | Table's max-height. The height of the table starts from `auto` until it reaches the maxHeight limit. The `maxHeight` is measured in pixels, same as `height` | string/number | — | — |
|
|
|
| stripe | whether table is striped | boolean | — | false |
|
|
|
| border | whether table has vertical border | boolean | — | false |
|
|
|
| fit | whether width of column automatically fits its container | boolean | — | true |
|
|
@@ -1187,6 +1369,7 @@ Customize table column so it can be integrated with other components.
|
|
|
| row-style | function that returns custom style for a row, or a string assigning custom style for every row | Function(row, index)/Object | — | — |
|
|
|
| row-key | key of row data, used for optimizing rendering. Required if `reserve-selection` is on | Function(row)/String | — | — |
|
|
|
| context | context of Table, e.g. `_self` refers to the current context, `$parent` parent context, `$root` root context, can be overridden by `context` in `el-table-column` | Object | - | current context where Table lies |
|
|
|
+| empty-text | Displayed text when data is empty. You can customize this area with `slot="empty"` | String | | - | No Data |
|
|
|
|
|
|
### Table Events
|
|
|
| Event Name | Description | Parameters |
|
|
@@ -1197,9 +1380,12 @@ Customize table column so it can be integrated with other components.
|
|
|
| cell-mouse-enter | triggers when hovering into a cell| row, column, cell, event |
|
|
|
| cell-mouse-leave | triggers when hovering out of a cell | row, column, cell, event |
|
|
|
| cell-click | triggers when clicking a cell | row, column, cell, event |
|
|
|
-| row-click | triggers when clicking a row | row, event |
|
|
|
+| row-click | triggers when clicking a row | row, event, column |
|
|
|
+| row-contextmenu | triggers when user right clicks on a row | row, event |
|
|
|
+| row-dblclick | triggers when double clicking a row | row, event |
|
|
|
| header-click | triggers when clicking a column header | column, event |
|
|
|
| sort-change | triggers when Table's sorting changes | { column, prop, order } |
|
|
|
+| filter-change | column's key. If you need to use the filter-change event, this attribute is mandatory to identify which column is being filtered | filters |
|
|
|
| current-change | triggers when current row changes | currentRow, oldCurrentRow |
|
|
|
|
|
|
### Table Methods
|
|
@@ -1213,6 +1399,7 @@ Customize table column so it can be integrated with other components.
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
|
|
| type | type of the column. If set to `selection`, the column will display checkbox. If set to `index`, the column will display index of the row (staring from 1) | string | selection/index | — |
|
|
|
| label | column label | string | — | — |
|
|
|
+| column-key | column's key. If you need to use the filter-change event, you need this attribute to identify which column is being filtered | string | string | - | - |
|
|
|
| prop | field name. You can also use its alias: `property` | string | — | — |
|
|
|
| width | column width | string | — | — |
|
|
|
| min-width | column minimum width. Columns with `width` has a fixed width, while columns with `min-width` has a width that is distributed in proportion | string | — | — |
|