富贵资源网 Design By www.hznty.com

本文实例为大家分享了bootstrap实现下拉框搜索展示的具体代码,供大家参考,具体内容如下

1.第一个下拉框代码

<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="搜索数据资源">
         <option value="">请选择数据资源</option>
         <optgroup label="UNESCO二类中心">
          <#list data.copyfromList as entity>
          <#if (entity.type"${entity.alias!}" <#if (param.copyfrom"科技动态与进展">
          <#list data.copyfromList as entity>
          <#if (entity.type"${entity.alias!}" <#if (param.copyfrom"其他">
          <#list data.copyfromList as entity>
          <#if (entity.type"${entity.alias!}" <#if (param.copyfrom"htmlcode">
<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"htmlcode">
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.后台java部分代码(接收参数,然后过滤器根据参数得到想要的结果)

   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);

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com