当前位置:网站首页>Elemtnui select control combined with tree control to realize user-defined search method
Elemtnui select control combined with tree control to realize user-defined search method
2022-06-25 12:43:00 【fortunate_ leixin】
Business needs : You can select data from the drop-down box , You can also customize your search .
Front end effect :
1: Select... From the drop-down box 
2: Custom search 
Code implementation :
1. First of all, we need to use select Controls and tree Control , stay select Control tree Control .
2. Turn on select Control , That is to say filterable, Then you need to customize the search method , That is to say filter-method This method .
3. Listen for the appearance and hiding of the drop-down box , That is, whether to pull down ,visible-change Method can be implemented .
4:tree Control filter method , That is, filter tree nodes through keywords ,elementui Of tree Control has instances ,filter-node-method Is the method of filtering .
Specific code :
<el-col :span="12">
<el-form-item label=" department " prop="deptName">
<el-select id="deptNameId"
v-model="certificateValue.deptName"
filterable placeholder=" Please select "
:filter-method="filterTreeDate"
@visible-change="changeValue($event)">
<el-option style="height: auto" value="deptName">
<el-tree
ref="treeForm"
:data="treeDatalist"
:props="defaultProps"
default-expand-all
node-key="id"
show-checkbox
check-strictly
:filter-node-method="filterNode"
@check="handleCheckChange"
/>
</el-option>
</el-select>
</el-form-item>
</el-col>
methods in :
// Custom filter method
filterTreeDate(val) {
this.certificateValue.deptName = val
this.$refs.treeForm.filter(val)
},
// The drop-down box appears / Trigger when hidden
changeValue(val) {
if (!val) {
this.$refs.treeForm.filter('')
}
},
// Filter
filterNode(value, data) {
if (!value) return true
return data.label.indexOf(value) !== -1
},
// Single selection and assignment
handleCheckChange(data, checked) {
this.certificateValue.deptName = data.label
this.certificateValue.deptId = data.id
if (checked.checkedKeys !== '') {
this.checkedId = data.id
this.$refs.treeForm.setCheckedKeys([data.id], true)
} else {
this.$refs.treeForm.setCheckedKeys([])
}
}
边栏推荐
- Repair the error that ECSHOP background orders prompt insufficient inventory when adding goods. Please reselect
- JS array length is defined
- 2021-09-30
- 阿里稳定性之故障应急处理流程
- Mind mapping video
- When MySQL queries fields in JSON format, it takes a property value of JSON data
- 2022 Baidu collection batch automatic push assistant
- An example of using dynamic datalist
- 浏览器的5种观察器
- JS function exercises
猜你喜欢

An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down

(6) Pyqt5--- > window jump (registration login function)

Today, I will explain to you what is DFI and its development prospects

Installation and removal of MySQL under Windows

Matlab simulation of m-sequence

聊聊高可用的 11 个关键技巧

Why are databases cloud native?

Zhangxiaobai's road of penetration (IV) -- detailed explanation of XSS cross site script vulnerabilities

冷启动的最优解决方案

Zhangxiaobai's way of penetration (VIII) - detailed operation steps of SQL injection - Boolean blind injection of blind injection
随机推荐
thinkphp3.2.5 GIF. class. php for php7.4
2022 Baidu collection batch automatic push assistant
Figure explanation of fiborache sequence
The source code of the hottest online disk money making system in 2022 imitates Lanzou online disk / Chengtong online disk / sharing money making cloud disk system / online disk VIP Download System
Micro engine generates QR code
Circular exercises of JS
(5) Pyqt5 ---- another method of connecting signals and slots
Node child processes and threads
Digital currency exchange -- digital currency exchange system development source code sharing
STM32 stores float data in flash
Concise H5 error page
Polling and long polling
高性能负载均衡架构如何实现?
2021-09-22
Visual studio2019 link opencv
An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down
JS SMS countdown implementation (simple code)
地理空间搜索:kd树的实现原理
Go novice exploration road 1
laravel 9