|
@@ -104,12 +104,73 @@
|
|
|
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: []
|
|
|
};
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
+ handleClick() {
|
|
|
+ console.log('click');
|
|
|
+ },
|
|
|
+
|
|
|
+ handleEdit(index, row) {
|
|
|
+ console.log(index, row);
|
|
|
+ },
|
|
|
+
|
|
|
+ handleDelete(index, row) {
|
|
|
+ console.log(index, row);
|
|
|
+ },
|
|
|
handleSelectionChange(val) {
|
|
|
this.multipleSelection = val;
|
|
|
},
|
|
@@ -133,6 +194,10 @@
|
|
|
return 'positive-row';
|
|
|
}
|
|
|
return '';
|
|
|
+ },
|
|
|
+
|
|
|
+ deleteRow(index, rows) {
|
|
|
+ rows.splice(index, 1);
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -144,7 +209,7 @@
|
|
|
};
|
|
|
</script>
|
|
|
|
|
|
-## Table
|
|
|
+## Table
|
|
|
|
|
|
Display multiple data with similar format. You can sort, filter, compare your data in a table.
|
|
|
|
|
@@ -460,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.
|
|
|
|
|
@@ -503,20 +568,24 @@ When there are too many columns, you can fix some of them.
|
|
|
width="120">
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
- inline-template
|
|
|
fixed="right"
|
|
|
label="Operations"
|
|
|
width="120">
|
|
|
- <span>
|
|
|
- <el-button type="text" size="small">Detail</el-button>
|
|
|
+ <template scope="scope">
|
|
|
+ <el-button @click="handleClick" type="text" size="small">Detail</el-button>
|
|
|
<el-button type="text" size="small">Edit</el-button>
|
|
|
- </span>
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
export default {
|
|
|
+ methods: {
|
|
|
+ handleClick() {
|
|
|
+ console.log('click');
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
tableData: [{
|
|
@@ -559,7 +628,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.
|
|
|
|
|
@@ -666,6 +735,240 @@ 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
|
|
|
+ fixed="right"
|
|
|
+ label="Operations"
|
|
|
+ width="120">
|
|
|
+ <template scope="scope">
|
|
|
+ <el-button
|
|
|
+ @click.native.prevent="deleteRow(scope.$index, tableData4)"
|
|
|
+ type="text"
|
|
|
+ size="small">
|
|
|
+ Remove
|
|
|
+ </el-button>
|
|
|
+ </template>
|
|
|
+ </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.
|
|
|
+
|
|
|
+:::demo Only need to place el-table-column inside a el-table-column, you can achieve group header.
|
|
|
+```html
|
|
|
+<template>
|
|
|
+ <el-table
|
|
|
+ :data="tableData3"
|
|
|
+ border
|
|
|
+ style="width: 100%">
|
|
|
+ <el-table-column
|
|
|
+ prop="date"
|
|
|
+ label="Date"
|
|
|
+ width="150">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="Delivery Info">
|
|
|
+ <el-table-column
|
|
|
+ prop="name"
|
|
|
+ label="Name"
|
|
|
+ width="120">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="Address Info">
|
|
|
+ <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>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData3: [{
|
|
|
+ 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>
|
|
|
+```
|
|
|
+:::
|
|
|
+
|
|
|
### Single select
|
|
|
|
|
|
Single row selection is supported.
|
|
@@ -738,24 +1041,22 @@ Single row selection is supported.
|
|
|
|
|
|
You can also select multiple rows.
|
|
|
|
|
|
-:::demo Activating multiple selection is easy: simply add an `el-table-column` with its `type` set to `selection`. Apart from multiple selection, this example also uses `inline-template` and `show-overflow-tooltip`: when the attribute `inline-template` is set, you can use custom template inside `el-table-column`, and access current row data via `row`; by default, if the content is too long, it will break into multiple lines. If you want to keep it in one line, use attribute `show-overflow-tooltip`, which accepts a `Boolean` value. When set `true`, the extra content will show in tooltip when hover on the cell.
|
|
|
+:::demo Activating multiple selection is easy: simply add an `el-table-column` with its `type` set to `selection`. Apart from multiple selection, this example also uses `show-overflow-tooltip`: by default, if the content is too long, it will break into multiple lines. If you want to keep it in one line, use attribute `show-overflow-tooltip`, which accepts a `Boolean` value. When set `true`, the extra content will show in tooltip when hover on the cell.
|
|
|
```html
|
|
|
<template>
|
|
|
<el-table
|
|
|
:data="tableData3"
|
|
|
border
|
|
|
- selection-mode="multiple"
|
|
|
style="width: 100%"
|
|
|
@selection-change="handleSelectionChange">
|
|
|
<el-table-column
|
|
|
type="selection"
|
|
|
- width="50">
|
|
|
+ width="55">
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
- inline-template
|
|
|
label="Date"
|
|
|
width="120">
|
|
|
- <div>{{ row.date }}</div>
|
|
|
+ <template scope="scope">{{ scope.row.date }}</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
property="name"
|
|
@@ -821,13 +1122,15 @@ You can also select multiple rows.
|
|
|
|
|
|
Sort the data to find or compare data quickly.
|
|
|
|
|
|
-:::demo Set attribute `sortable` in a certain column to sort the data based on this column. It accepts `Boolean` with a default value `false`. In this example we use another attribute named `formatter` to format the value of certain columns. It accepts a function which has two parameters: `row` and `column`. You can handle it according to your own needs.
|
|
|
+:::demo Set table attribute `default-sort-prop` and `default-sort-order` to determine default sort column and order. Set attribute `sortable` in a certain column to sort the data based on this column. It accepts `Boolean` with a default value `false`. In this example we use another attribute named `formatter` to format the value of certain columns. It accepts a function which has two parameters: `row` and `column`. You can handle it according to your own needs.
|
|
|
```html
|
|
|
<template>
|
|
|
<el-table
|
|
|
:data="tableData"
|
|
|
border
|
|
|
- style="width: 100%">
|
|
|
+ style="width: 100%"
|
|
|
+ default-sort-prop="date"
|
|
|
+ default-sort-order="descending">
|
|
|
<el-table-column
|
|
|
prop="date"
|
|
|
label="Date"
|
|
@@ -912,9 +1215,12 @@ Filter the table to find desired data.
|
|
|
label="Tag"
|
|
|
width="100"
|
|
|
:filters="[{ text: 'Home', value: 'Home' }, { text: 'Office', value: 'Office' }]"
|
|
|
- :filter-method="filterTag"
|
|
|
- inline-template>
|
|
|
- <el-tag :type="row.tag === 'Home' ? 'primary' : 'success'" close-transition>{{row.tag}}</el-tag>
|
|
|
+ :filter-method="filterTag">
|
|
|
+ <template scope="scope">
|
|
|
+ <el-tag
|
|
|
+ :type="scope.row.tag === 'Home' ? 'primary' : 'success'"
|
|
|
+ close-transition>{{scope.row.tag}}</el-tag>
|
|
|
+ </template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
</template>
|
|
@@ -959,17 +1265,198 @@ Filter the table to find desired data.
|
|
|
```
|
|
|
:::
|
|
|
|
|
|
+### Custom column template
|
|
|
+
|
|
|
+Customize table column so it can be integrated with other components.
|
|
|
+:::demo You have access to the following data: row, column, $index and store (state management of Table) by [Scoped slot](https://vuejs.org/v2/guide/components.html#Scoped-Slots). (Scoped slots is supported from `1.1`, `inline-template` still works, but it's not recommended).
|
|
|
+```html
|
|
|
+<template>
|
|
|
+ <el-table
|
|
|
+ :data="tableData"
|
|
|
+ border
|
|
|
+ style="width: 100%">
|
|
|
+ <el-table-column
|
|
|
+ label="Date"
|
|
|
+ width="180">
|
|
|
+ <template scope="scope">
|
|
|
+ <el-icon name="time"></el-icon>
|
|
|
+ <span style="margin-left: 10px">{{ scope.row.date }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="Name"
|
|
|
+ width="180">
|
|
|
+ <template scope="scope">
|
|
|
+ <el-popover trigger="hover" placement="top">
|
|
|
+ <p>Name: {{ scope.row.name }}</p>
|
|
|
+ <p>Addr: {{ scope.row.address }}</p>
|
|
|
+ <div slot="reference" class="name-wrapper">
|
|
|
+ <el-tag>{{ scope.row.name }}</el-tag>
|
|
|
+ </div>
|
|
|
+ </el-popover>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ :context="_self"
|
|
|
+ label="Operations">
|
|
|
+ <template scope="scope">
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ @click="handleEdit(scope.$index, scope.row)">Edit</el-button>
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="danger"
|
|
|
+ @click="handleDelete(scope.$index, scope.row)">Delete</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData: [{
|
|
|
+ date: '2016-05-03',
|
|
|
+ name: 'Tom',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-02',
|
|
|
+ name: 'Tom',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-04',
|
|
|
+ name: 'Tom',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles'
|
|
|
+ }, {
|
|
|
+ date: '2016-05-01',
|
|
|
+ name: 'Tom',
|
|
|
+ address: 'No. 189, Grove St, Los Angeles'
|
|
|
+ }]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleEdit(index, row) {
|
|
|
+ console.log(index, row);
|
|
|
+ },
|
|
|
+ handleDelete(index, row) {
|
|
|
+ console.log(index, row);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+```
|
|
|
+:::
|
|
|
+
|
|
|
+### Expandable row
|
|
|
+
|
|
|
+When the row content is too long and you do not want to display the horizontal scroll bar, you can use the expandable row feature.
|
|
|
+:::demo Activate expandable row by adding type="expand" and scoped slot. The template for el-table-column will be rendered as the contents of the expanded row, and you can access the same attributes as when you are using `Scoped slot` in custom column templates.
|
|
|
+```html
|
|
|
+<template>
|
|
|
+ <el-table
|
|
|
+ :data="tableData3"
|
|
|
+ style="width: 100%">
|
|
|
+ <el-table-column type="expand">
|
|
|
+ <template scope="props">
|
|
|
+ <p>State: {{ props.row.state }}</p>
|
|
|
+ <p>City: {{ props.row.city }}</p>
|
|
|
+ <p>Address: {{ props.row.address }}</p>
|
|
|
+ <p>Zip: {{ props.row.zip }}</p>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="Date"
|
|
|
+ prop="date">
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column
|
|
|
+ label="Name"
|
|
|
+ prop="name">
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+ export default {
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ tableData3: [{
|
|
|
+ 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>
|
|
|
+```
|
|
|
+:::
|
|
|
+
|
|
|
### Table Attributes
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
|
|
| data | table data | array | — | — |
|
|
|
-| height | table's height. By default | 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 |
|
|
|
+| show-header | whether table header is visible | boolean | — | true |
|
|
|
| highlight-current-row | whether current row is highlighted | boolean | — | false |
|
|
|
-| row-class-name | function that returns custom class names for a row | Function(row, index) | — | — |
|
|
|
-| row-key | Key of row data, used for optimizing rendering. Required if `reserve-selection` is on | Function(row)/String | — | — |
|
|
|
+| current-row-key | key of current row, a set only prop | string,number | — | — |
|
|
|
+| row-class-name | function that returns custom class names for a row, or a string assigning class names for every row | Function(row, index)/String | — | — |
|
|
|
+| 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 |
|
|
|
+| default-expand-all | whether expand all rows by default, only works when the table has a column type="expand" | Boolean | — | false |
|
|
|
+| expand-row-keys | set expanded rows by this prop, prop's value is the keys of expand rows, you should set row-key before using this prop | Array | — | |
|
|
|
+| default-sort-prop | set the `prop` of default sort column. | String | - | - |
|
|
|
+| default-sort-order | set the default sort order. You should set `default-sort-prop` before using this prop. | String | ascending, descending | ascending |
|
|
|
|
|
|
### Table Events
|
|
|
| Event Name | Description | Parameters |
|
|
@@ -980,12 +1467,17 @@ Filter the table to find desired data.
|
|
|
| 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 |
|
|
|
+| expand | triggers when user expands or collapses a row | row, expanded |
|
|
|
|
|
|
### Table Methods
|
|
|
-| Method | Description | Parameter |
|
|
|
+| Method | Description | Parameters |
|
|
|
|------|--------|-------|
|
|
|
| clearSelection | clear selection, might be useful when `reserve-selection` is on | selection |
|
|
|
| toggleRowSelection | toggle if a certain row is selected. With the second parameter, you can directly set if this row is selected | row, selected |
|
|
@@ -993,8 +1485,9 @@ Filter the table to find desired data.
|
|
|
### Table-column Attributes
|
|
|
| Attribute | Description | Type | Accepted Values | Default |
|
|
|
|---------- |-------------- |---------- |-------------------------------- |-------- |
|
|
|
-| 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 | — |
|
|
|
+| 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). If set to `expand`, the column will display expand icon. | string | selection/index/expand | — |
|
|
|
| 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 | — | — |
|
|
@@ -1005,8 +1498,8 @@ Filter the table to find desired data.
|
|
|
| resizable | whether column width can be resized, works when `border` of `el-table` is `true` | boolean | — | false |
|
|
|
| formatter | function that formats content | Function(row, column) | — | — |
|
|
|
| show-overflow-tooltip | whether to hide extra content and show them in a tooltip when hovering on the cell | boolean | — | false |
|
|
|
-| inline-template | by using this attribute, you can customize column template. Row data can be accessed by `row` object, and current context can be accessed by `_self` in JSX. In this case you don't need to set `prop`. In your template, you have access to the following: `{ row (current row), column (current column), $index (row index), _self( context), store (table store) }` | — | — |
|
|
|
| align | alignment | string | left/center/right | left |
|
|
|
+| header-align | alignment of the table header. If omitted, the value of the above `align` attribute will be applied | String | left/center/right | — |
|
|
|
| class-name | class name of cells in the column | string | — | — |
|
|
|
| selectable | function that determines if a certain row can be selected, works when `type` is 'selection' | Function(row, index) | — | — |
|
|
|
| reserve-selection | whether to reserve selection after data refreshing, works when `type` is 'selection' | boolean | — | false |
|