当前位置:网站首页>EasyUI's combobox implements three-level query
EasyUI's combobox implements three-level query
2022-04-23 03:12:00 【A happy wild pointer D】
1、 Business needs
Select a dormitory building , Then choose a floor of the building , Then choose a bedroom on this floor
2、 Realize the idea
First query the list of dormitory buildings from the database , Initialize the combo box of the dormitory building , Let the user choose one of them , After choosing, transfer the building to the backstage , Let the background find out which floors the building has according to this value , Fill the query results into the combo box of the floor , After the user selects again, the floor and dormitory building will be returned to the background , The background queries the building according to these two parameters 、 All dormitories on this floor
3、 The front-end code
<div>
<span> Dormitory building </span>
<input id="bid" class="easyui-combobox" name="bid"
data-options="
url:'${pageContext.request.contextPath}/getbid.action',// Background method of loading dormitory data
method:'get',
valueField:'id',
textField:'text',
editable:false,
// When a user selects an item , Trigger this event ,rec For the user's current selection
onSelect:function(rec){
var bid=rec.text;// Value
$('#floor').combobox('clear');// Clear the option of the previous floor
// Background method of loading floor data , Splice parameters to url On
var url='${pageContext.request.contextPath}/getfloor.action?bid='+bid;
$('#floor').combobox('reload',url);// Reload the data of the floor
}" />
<span> floor </span>
<input id="floor" class="easyui-combobox" name="floor"
data-options="
valueField:'id',
textField:'text',
editable:false,
onSelect:function(rec){
var bid=$('#bid').combobox('getValue');
var floor=rec.text;
// Clear the previous dormitory options
$('#room').combobox('clear');
// Background method of loading dormitory , Splice parameters to url On
var url='${pageContext.request.contextPath}/getroom.action?bid='+bid+'&floor='+floor;
$('#room').combobox('reload',url);// Reload
}" />
<span> dormitory </span>
<input id="room" class="easyui-combobox" name="room"
data-options="
valueField:'id',
textField:'text',
editable:false
" />
<a id="search-btn" href="javascript:;" class="easyui-linkbutton" plain="true" iconCls="icon-search"> Inquire about </a>
</div>
of no avail JavaScript Assign your own... To the floor and dormitory number url Because my floor and dormitory must have parameters , If in script The... They load is given in url, When the page is loaded, it will automatically go to the background to execute the method , But at this time, the dormitory building has not chosen , Therefore, there are no parameters , Browser's console You're going to report a mistake , Cause the program cannot continue to execute
4、 Background code
controller
/**
* Check all dormitory buildings
* @return
*/
@RequestMapping(value="/getbid.action")
@ResponseBody
public List<ComboboxModel> getBid()
{
List<ComboboxModel> models=new ArrayList<>();
List<String> list = dormManageService.getRDbidType();
for (String item : list) {
models.add(new ComboboxModel(item,item));
}
System.out.println(models.toString());
return models;
}
/**
* Query the number of floors of the selected dormitory building
* @param bid Selected dormitory building
* @return
*/
@RequestMapping(value="/getfloor.action")
@ResponseBody
public List<ComboboxModel> getFloor(@RequestParam("bid")String bid)
{
List<ComboboxModel> models=new ArrayList<>();
List<String> list = dormManageService.getRDfloorType(bid);
for (String item : list) {
models.add(new ComboboxModel(item,item));
}
System.out.println(models.toString());
return models;
}
/**
* Query the dormitory number of the selected floor
* @param bid Selected dormitory building
* @param floor Selected floor
* @return
*/
@RequestMapping(value="/getroom.action")
@ResponseBody
public List<ComboboxModel> getRoom(@RequestParam("bid")String bid,@RequestParam("floor") String floor)
{
List<ComboboxModel> models=new ArrayList<>();
List<String> list = dormManageService.getRDroomType(bid, floor);
for (String item : list) {
models.add(new ComboboxModel(item,item));
}
System.out.println(models.toString());
return models;
}
Specifically for combobox Built for pojo
package com.pojo;
public class ComboboxModel {
private String id;// Used as a combobox Of value
private String text;// Used as a combobox Of text
public ComboboxModel() {
super();
}
public ComboboxModel(String id, String text) {
super();
this.id = id;
this.text = text;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
@Override
public String toString() {
return "ComboboxModel [id=" + id + ", text=" + text + "]";
}
}
版权声明
本文为[A happy wild pointer D]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220627538442.html
边栏推荐
- 2022山东省安全员C证上岗证题库及在线模拟考试
- First in the binary tree
- 2022 Shandong Province safety officer C certificate work certificate question bank and online simulation examination
- Establishing and traversing binary tree
- Swap the left and right of each node in a binary tree
- PID debugging of coding motor (speed loop | position loop | follow)
- 使用DFS来解决“字典序排数”问题
- 《C语言程序设计》(谭浩强第五版) 第7章 用函数实现模块化程序设计 习题解析与答案
- MYSQL04_ Exercises corresponding to arithmetic, logic, bit, operator and operator
- ASP. Net 6 middleware series - execution sequence
猜你喜欢

TP5 inherits base and uses the variables in base

OLED multi-level menu record

The most easy to understand dependency injection and control inversion

AOT和单文件发布对程序性能的影响

Maui initial experience: Cool

手机连接电脑后,QT的QDIR怎么读取手机文件路径

How does Microsoft solve the problem of multiple programs on PC side -- internal implementation

Fight leetcode again (290. Word law)

ASP.NET 6 中间件系列 - 执行顺序

The backtracking of stack is used to solve the problem of "the longest absolute path of file"
随机推荐
使用split来解决“最常见的单词”问题
C# 读写二进制文件
Openfeign timeout setting
C语言实现通讯录----(静态版本)
Mise en service PID du moteur de codage (anneau de vitesse | anneau de position | suivant)
How does Microsoft solve the problem of multiple programs on PC side -- internal implementation
搭建XAMPP时mysql端口被占用
Source code interpretation of Flink index parameters (read quantity, sent quantity, sent bytes, received bytes, etc.)
Source Generator实战
2022年度Top9的任务管理系统
Xamarin effect Chapter 22 recording effect
Middle and rear binary tree
Blazor University (12) - component lifecycle
Tencent video price rise: earn more than 7.4 billion a year! Pay attention to me to receive Tencent VIP members, and the weekly card is as low as 7 yuan
C WPF UI framework mahapps switching theme
求二叉树的叶子结点个数
MYSQL04_ Exercises corresponding to arithmetic, logic, bit, operator and operator
Openfeign details show
Mysql database
Miniapi of. Net7 (special section): NET7 Preview3