当前位置:网站首页>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
边栏推荐
- Improvement of ref and struct in C 11
- Maui initial experience: Cool
- The most easy to understand dependency injection and control inversion
- OLED多级菜单记录
- Source code interpretation of Flink index parameters (read quantity, sent quantity, sent bytes, received bytes, etc.)
- [untitled]
- Source generator actual combat
- ASP. Net 6 middleware series - conditional Middleware
- 使用DFS来解决“字典序排数”问题
- Drawing polygons with < polygon / > circular array in SVG tag
猜你喜欢

Mise en service PID du moteur de codage (anneau de vitesse | anneau de position | suivant)

Top ten project management software similar to JIRA

C language to achieve address book - (static version)
![[new version release] componentone added Net 6 and blazor platform control support](/img/08/71e7328f685a5cdd584f1bfdce5f2a.png)
[new version release] componentone added Net 6 and blazor platform control support

Laravel8- use JWT

2022G2电站锅炉司炉考试题库及在线模拟考试

2022年度Top9的任务管理系统

TP5 customization in extend directory succeeded and failed. Return information

The most detailed in the whole network, software testing measurement, how to optimize software testing cost and improve efficiency --- hot

Tencent video VIP member, weekly card special price of 9 yuan! Tencent official direct charging, members take effect immediately!
随机推荐
最通俗易懂的依赖注入与控制反转
求二叉树的叶子结点个数
C语言实现通讯录----(静态版本)
OLED multi-level menu record
使用栈来解决”迷你语法分析器“的问题
2022a special equipment related management (elevator) work license question bank and simulation examination
2022 P cylinder filling training test questions and simulation test
C# 读写二进制文件
手机连接电脑后,QT的QDIR怎么读取手机文件路径
C WPF UI framework mahapps switching theme
MAUI初体验:爽
OLED多级菜单记录
yes. Net future
Array and collection types passed by openfeign parameters
Simple example of using redis in PHP
再战leetcode (290.单词规律)
宁德时代地位不保?
Drawing polygons with < polygon / > circular array in SVG tag
Openfeign timeout setting
Impact of AOT and single file release on program performance