element-ui-table-span-method
Element-UI el-table's attribute span-method
.
Installing
npm install element-ui-table-span-method
Usage
import { spanRow } from "element-ui-table-span-method";
API
spanRow({ row, column, rowIndex, columnIndex }, data, option)
Span table's row.
<template>
<el-table :data="data" :span-method="onSpanMethod">
<el-table-column prop="field1" label="field1"> </el-table-column>
<el-table-column prop="field2" label="field2"> </el-table-column>
<el-table-column prop="field3" label="field3"> </el-table-column>
</el-table>
</template>
<script>
import { spanRow } from "element-ui-table-span-method";
export default {
data() {
return {
data: [
{ field1: "A", field2: "a", field3: "1" },
{ field1: "A", field2: "a", field3: "2" },
{ field1: "A", field2: "b", field3: "3" }
],
option: [
{ index: 0, field: "field1" },
{ index: 1, field: "field2" }
]
};
},
methods: {
onSpanMethod({ row, column, rowIndex, columnIndex }) {
return spanRow(
{ row, column, rowIndex, columnIndex },
this.data,
this.option
);
}
}
};
</script>
field1 | field2 | field3 |
---|---|---|
A | a | 1 |
A | a | 2 |
A | b | 3 |
↓
field1 | field2 | field3 |
---|---|---|
A | a | 1 |
2 | ||
b | 3 |