vxe-table 单选设置允许取消选中
<p>vxe-table 单选设置允许取消选中,通过设置 radio-row-config.strict=false 允许取消选中</p><p>https://vxetable.cn</p>
<p><img src="https://img2024.cnblogs.com/blog/3766032/202603/3766032-20260309163701408-1104023517.gif"></p>
<p>设置 radio-row-config.strict=false 允许取消选中</p>
<pre><code class="language-html"><template>
<div>
<vxe-grid v-bind="gridOptions"></vxe-grid>
</div>
</template>
<script>
export default {
data() {
const gridOptions = {
border: true,
height: 300,
rowConfig: {
isHover: true
},
radioConfig: {
labelField: 'name',
strict: false
},
columns: [
{ type: 'radio', title: 'Name', width: 300 },
{ field: 'id', title: 'ID' },
{ field: 'age', title: 'Age' },
{ field: 'address', title: 'Address', showOverflow: true }
],
data: [
{ id: 10001, name: 'Test1', role: 'Develop', sex: 'Man', age: 28, address: 'test abc' },
{ id: 10002, name: 'Test2', role: 'Test', sex: 'Women', age: 22, address: 'Guangzhou' },
{ id: 10003, name: 'Test3', role: 'PM', sex: 'Man', age: 32, address: 'Shanghai' },
{ id: 10004, name: 'Test4', role: 'Designer', sex: 'Women', age: 23, address: 'test abc' },
{ id: 10005, name: 'Test5', role: 'Develop', sex: 'Women', age: 30, address: 'Shanghai' }
]
};
return {
gridOptions
};
}
};
</script>
</code></pre>
<p>https://gitee.com/x-extends/vxe-table</p><br><br>
来源:https://www.cnblogs.com/leid6/p/19690927 感谢分享!这个功能确实很实用,之前用 vxe-table 的时候还被单选不能取消困扰过。
另外补充一下:
strict 属性说明:
- strict=true(默认):必须选中一行,无法取消选中状态
- strict=false:允许取消选中,点击已选中的行可以取消选择
这个配置对于一些需要"取消选择"场景的功能特别有用,比如表单中的可选项、筛选条件等。
已收藏备用,感谢楼主的分享!
源码公社 - 每天进步一点点!
页:
[1]