当前位置:网站首页>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([])
}
}
边栏推荐
- Write regular isosceles triangle and inverse isosceles triangle with for loop in JS
- Visual studio2019 link opencv
- mysql FIND_ IN_ Set function
- Three jobs! You can learn this from me (attached with graduation vlog)
- flutter 收到推送后自动消失问题
- Draw the satellite sky map according to the azimuth and elevation of the satellite (QT Implementation)
- 2021-10-21
- JS array length is defined
- el-select clear 清空内容时触发事件
- 百度搜索稳定性问题分析的故事
猜你喜欢
![Maximum number [abstract rules for abstract sorting]](/img/47/f6bafacc95f487854a3e304325f3f0.png)
Maximum number [abstract rules for abstract sorting]

Render values to corresponding text

Go from 0 to 1. Obtain the installation package, get, post request, params, body and other parameters

Shell learning notes (latest update: 2022-02-18)
![Select randomly by weight [prefix and + dichotomy + random target]](/img/84/7f930f55f8006a4bf6e23ef05676ac.png)
Select randomly by weight [prefix and + dichotomy + random target]

2021-09-28

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

Guess Tongyuan B

Idea2017 how to set not to automatically open a project at startup

Three jobs! You can learn this from me (attached with graduation vlog)
随机推荐
Summary of common MySQL database commands (from my own view)
flutter 收到推送后自动消失问题
聊聊高可用的 11 个关键技巧
An article clearly explains MySQL's clustering / Federation / coverage index, back to table, and index push down
High performance + million level Excel data import and export
Disconnected: No supported authentication methods available (server sent: )
PHP multidimensional array sorting
GPS receiver design (1)
Slice and slice methods of arrays in JS
2021-09-28
Execution order of MySQL query statements join, on and where
Introduction to jiuhongtianxia system development function -- jiuhongtianxia app development source code sharing
Zhangxiaobai's way of penetration (III) -- detailed explanation of SQL injection vulnerability principle (SQL Server)
JQ dynamic setting radio does not take effect when selected
ECSHOP commodity page multi-attribute batch purchase plug-ins ECSHOP wholesale plug-ins multi-attribute order placing, multi-attribute batch purchase of commodities
Laravel task scheduling
Mind mapping video
Heyangdao store management system -- share the development source code of heyangdao system
(7) Pyqt5 tutorial -- > > window properties and basic controls (continuous update)
Flutter automatically disappears after receiving push