Home  >  Article  >  Web Front-end  >  Detailed explanation of Bootstrap Table search box and query function

Detailed explanation of Bootstrap Table search box and query function

小云云
小云云Original
2018-01-05 11:23:438422browse

This article mainly introduces the Bootstrap Table search box and query function. It is very good and has reference value. Friends in need can refer to it. I hope it can help everyone.

1. Knowledge points bootstrapTable refresh and query configuration

2. Improve js code performance

1. Reduce global variable declarations

2. Cache dom Node search results

3. Local variables cache global variables

/** 
 * @param col bootstrapTable列表生成配置对象 
 */ 
var searchValue ={};//查询匹配对象 
var $button = $('

');  var $input = $('

');  var $select = $('

');  var addSearchGroup = function(col)  {     // 插入选项     var button ,input,select;     button = $button;input = $input;select = $select;////局部变量缓存全局变量 提高代码性能     var selectDom = $select.find('select');////缓存dom节点查找结果 避免在循环里用     for(var i = 0; i < col.length; i++){ if(col[i].visible != false){ var $option = '';         selectDom.append($option);       }     }     //插入多选框、输入框、按钮     $('.fixed-table-toolbar').append(button,input,select);  }  /*  button = $button  */  searchAction($button);  function searchAction(button){    //写入上一次查询的条件     if(searchValue.select != undefined){       $select.find('select').val(searchValue.select);     };     if(searchValue.input != undefined){       $input.find('input').val(searchValue.input);     };     //写入查询条件     // 获取查询选项     button.click(function(){        var option = $select.find('select').val();        var inputval = $input.find('input').val();        searchValue.select =option;        searchValue.inputval =inputval;     //定义刷新参数       if(inputval != ''){         var param = {           url: sWebRootPath+"/json/getAjaxData.jsp?v="+new Date().getTime(),           query: {             filters:[               {'colname':option,'filtertype':'LIKE','filtervalues':inputval}             ]           }         }       }else{         var param = {          url: sWebRootPath+"/json/getAjaxData.jsp?v="+new Date().getTime(),         }       }        // 刷新表格      $('#tablelist').bootstrapTable('refresh',param);      });  }

Related recommendations:

Detailed explanation of how PHP implements a simple search box automatic prompt function

jquery implements a search box similar to Baidu

HTML implements a fixed floating semi-transparent search box on the mobile side

The above is the detailed content of Detailed explanation of Bootstrap Table search box and query function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn