itable 添加设置默认选中行的功能
This commit is contained in:
parent
8f48491aa6
commit
1594942f2c
2 changed files with 40 additions and 1 deletions
|
@ -548,7 +548,11 @@
|
||||||
this.data.forEach((row, index) => {
|
this.data.forEach((row, index) => {
|
||||||
const newRow = deepCopy(row);// todo 直接替换
|
const newRow = deepCopy(row);// todo 直接替换
|
||||||
newRow._isHover = false;
|
newRow._isHover = false;
|
||||||
newRow._isChecked = false;
|
if(newRow.checked){// 传checked:true 可以设置该行为默认选中状态
|
||||||
|
newRow._isChecked = newRow.checked;
|
||||||
|
}else{
|
||||||
|
newRow._isChecked = false;
|
||||||
|
}
|
||||||
newRow._isHighlight = false;
|
newRow._isHighlight = false;
|
||||||
data[index] = newRow;
|
data[index] = newRow;
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<i-table border :content="self" :columns="columns7" :data="data6"></i-table>
|
<i-table border :content="self" :columns="columns7" :data="data6"></i-table>
|
||||||
|
|
||||||
|
默认选中行
|
||||||
|
<i-table border :content="self" :columns="columns8" :data="data8"></i-table>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
|
@ -64,6 +67,38 @@
|
||||||
age: 26,
|
age: 26,
|
||||||
address: '深圳市南山区深南大道'
|
address: '深圳市南山区深南大道'
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
columns8:[
|
||||||
|
{
|
||||||
|
type: 'selection',
|
||||||
|
width: 60,
|
||||||
|
align: 'center'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '名称',
|
||||||
|
key: 'name'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '年龄',
|
||||||
|
key: 'age'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '地址',
|
||||||
|
key: 'address'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
data8:[
|
||||||
|
{
|
||||||
|
name: '王小明',
|
||||||
|
age: 18,
|
||||||
|
address: '北京市朝阳区芍药居',
|
||||||
|
checked:true // 传checked 可以设置该行为默认选中状态
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '张小刚',
|
||||||
|
age: 25,
|
||||||
|
address: '北京市海淀区西二旗'
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue