bootstrap實(shí)現(xiàn)多個(gè)下拉框同時(shí)搜索的實(shí)例
1、第一個(gè)下拉框代碼
<div class="btn-group col-sm-3 col-xs-6 util-btn-margin-bottom-5 quick-search"> <!--快速查詢--> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-search"></i></span> <select data-filter-type="2" name="copyfrom" class="form-control select2" data-validate="notempty" style="visibility: hidden;" data-field="name" data-placeholder="搜索數(shù)據(jù)資源"> <option value="">請(qǐng)選擇數(shù)據(jù)資源</option> <optgroup label="UNESCO二類中心"> <#list data.copyfromList as entity> <#if (entity.type?? && entity.type == '1')> <option value="${entity.alias!}" <#if (param.copyfrom?? && param.copyfrom == entity.alias)>selected</#if>>${entity.alias!}</option> </#if> </#list> </optgroup> <optgroup label="科技動(dòng)態(tài)與進(jìn)展"> <#list data.copyfromList as entity> <#if (entity.type?? && entity.type == '7')> <option value="${entity.alias!}" <#if (param.copyfrom?? && param.copyfrom == entity.alias)>selected</#if>>${entity.alias!}</option> </#if> </#list> </optgroup> <optgroup label="其他"> <#list data.copyfromList as entity> <#if (entity.type?? && entity.type == '8')> <option value="${entity.alias!}" <#if (param.copyfrom?? && param.copyfrom == entity.alias)>selected</#if>>${entity.alias!}</option> </#if> </#list> </optgroup> </select> </div> </div>
2、第二個(gè)下拉框代碼
<div class="btn-group col-sm-3 col-xs-6 util-btn-margin-bottom-5 quick-search"> <!--快速查詢--> <div class="input-group"> <span class="input-group-addon"><i class="fa fa-search"></i></span> <select data-filter-type="2" name="cid" class="form-control select2" data-validate="notempty" style="visibility: hidden;" data-field="name" data-placeholder="搜索欄目名稱"> <option value=""></option> <#list data.categories as entity> <option value="${entity.id}" <#if (param.cid?? && param.cid == entity.id)>selected</#if>>${entity.id} - ${entity.name}</option> </#list> </select> </div> </div>
3、后臺(tái)js代碼(url 參數(shù)整理)
bindEvents:function(){ var self = this, dom = self.element; $('select[name="copyfrom"]', dom).change(function(event){ self.params.copyfrom = $(this).val(); var url = self.formatParams(self.params); window.location.href = "cekasp_article.htm" + url; }); $('select[name="cid"]', dom).change(function(event){ self.params.cid = $(this).val(); var url = self.formatParams(self.params); window.location.href = "cekasp_article.htm" + url; }); } formatParams:function(params){ var self = this; var url = ""; for(var param in params){ if(params[param]){ url += param + "=" + params[param] + "&"; } } if(url.length > 0){ url = "?" + url.substring(0,url.length-1); } return url; }
4、后臺(tái)java部分代碼(接收參數(shù),然后過(guò)濾器根據(jù)參數(shù)得到想要的結(jié)果)
String categoryId = request.optString("cid"); if (!ValidateUtil.isNull(categoryId)) { // 加載欄目信息 JSONObject jsonCategory = toJSONObject(adminService.loadById(CekaspCategory.class, categoryId)); response.put("category", jsonCategory); param.addFilter("id", FilterType.IN, articleIdList, 1); } String copyfrom = request.optString("copyfrom"); if (!ValidateUtil.isNull(copyfrom)) { param.addFilter("copyfrom", FilterType.EQUALS, copyfrom); } List<CekaspArticle> articleList = adminService.list(CekaspArticle.class,param);
以上這篇bootstrap實(shí)現(xiàn)多個(gè)下拉框同時(shí)搜索的實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
java獲取登錄者IP和登錄時(shí)間的兩種實(shí)現(xiàn)代碼詳解
這篇文章主要介紹了java獲取登錄者IP和登錄時(shí)間的實(shí)現(xiàn)代碼,本文通過(guò)兩種結(jié)合實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-07-07Java中的WeakHashMap概念原理以及簡(jiǎn)單案例
這篇文章主要介紹了Java中的WeakHashMap概念原理以及簡(jiǎn)單案例,WeakHashMap使用了軟引用結(jié)構(gòu),它的對(duì)象在垃圾回收時(shí)會(huì)被刪除,垃圾回收是優(yōu)先級(jí)非常低的線程,不能被顯示調(diào)用,當(dāng)內(nèi)存不足的時(shí)候會(huì)啟用,需要的朋友可以參考下2023-09-09SpringBoot服務(wù)端數(shù)據(jù)校驗(yàn)過(guò)程詳解
這篇文章主要介紹了SpringBoot服務(wù)端數(shù)據(jù)校驗(yàn)過(guò)程詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-02-02通過(guò)java api實(shí)現(xiàn)解壓縮zip示例
這篇文章主要介紹了通過(guò)java api實(shí)現(xiàn)解壓縮zip示例,需要的朋友可以參考下2014-04-04如何使用Java 8 中的 Stream 遍歷樹形結(jié)構(gòu)
這篇文章主要介紹了使用Java 8中的Stream遍歷樹形結(jié)構(gòu),我們可以使用Java8中的Stream流一次性把數(shù)據(jù)查出來(lái),然后通過(guò)流式處理,我們一起來(lái)看看,代碼實(shí)現(xiàn)為了實(shí)現(xiàn)簡(jiǎn)單,就模擬查看數(shù)據(jù)庫(kù)所有數(shù)據(jù)到List里面,需要的朋友可以參考下2023-08-08Mybatis如何傳入多個(gè)參數(shù)(實(shí)體類型和基本類型)
這篇文章主要介紹了Mybatis如何傳入多個(gè)參數(shù)(實(shí)體類型和基本類型),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-06-06