1.bootstrap-table对于前端的搜索可以通过官网设置,但发现前端搜索出现bug,网上找到一个bootstrap-table的扩充js  bootstrap-table-mytoolbar.js,可以通过结合bootstrap-table简单的配置就可以进行使用,结合实例说明:

bootstrap-table的扩充js内容:

 /**
* @author: aperez <aperez@datadec.es>
* @version: v2.0.0
*
* @update Dennis Hernández <http://djhvscf.github.io/Blog>
*/ !function($) {
'use strict'; var firstLoad = false; var sprintf = $.fn.bootstrapTable.utils.sprintf; var showAvdSearch = function(that) {
var timeoutId=0;
$('#'+ that.options.idTable).off('keyup blur', 'input').on('keyup blur', 'input', function (event) {
clearTimeout(timeoutId);
timeoutId = setTimeout(function () {
that.onColumnAdvancedSearch(event);
}, that.options.searchTimeOut);
});
}; $.extend($.fn.bootstrapTable.defaults, {
advancedSearch: false,
actionForm: '',
idTable: undefined,
onColumnAdvancedSearch: function (field, text) {
return false;
}
}); $.extend($.fn.bootstrapTable.defaults.icons, {
advancedSearchIcon: 'glyphicon-chevron-down'
}); $.extend($.fn.bootstrapTable.Constructor.EVENTS, {
'column-advanced-search.bs.table': 'onColumnAdvancedSearch'
}); $.extend($.fn.bootstrapTable.locales, {
formatAdvancedSearch: function() {
return 'Advanced search';
},
formatAdvancedCloseButton: function() {
return "Close";
}
}); $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales); var BootstrapTable = $.fn.bootstrapTable.Constructor,
_initToolbar = BootstrapTable.prototype.initToolbar,
_load = BootstrapTable.prototype.load,
_initSearch = BootstrapTable.prototype.initSearch; BootstrapTable.prototype.initToolbar = function() {
_initToolbar.apply(this, Array.prototype.slice.apply(arguments)); /*if (!this.options.search) {
return;
}*/ if (!this.options.advancedSearch) {
return;
} if (!this.options.idTable) {
return;
} var that = this;
showAvdSearch(that);
}; BootstrapTable.prototype.load = function(data) {
_load.apply(this, Array.prototype.slice.apply(arguments)); if (!this.options.advancedSearch) {
return;
} if (typeof this.options.idTable === 'undefined') {
return;
} else {
if (!firstLoad) {
var height = parseInt($(".bootstrap-table").height());
height += 10;
$("#" + this.options.idTable).bootstrapTable("resetView", {height: height});
firstLoad = true;
}
}
}; BootstrapTable.prototype.initSearch = function () {
_initSearch.apply(this, Array.prototype.slice.apply(arguments)); if (!this.options.advancedSearch) {
return;
} var that = this;
var fp = $.isEmptyObject(this.filterColumnsPartial) ? null : this.filterColumnsPartial; this.data = fp ? $.grep(this.data, function (item, i) {
for (var key in fp) {
var fval = fp[key].toLowerCase();
var value = item[key];
value = $.fn.bootstrapTable.utils.calculateObjectValue(that.header,
that.header.formatters[$.inArray(key, that.header.fields)],
[value, item, i], value); if (!($.inArray(key, that.header.fields) !== -1 &&
(typeof value === 'string' || typeof value === 'number') &&
(value + '').toLowerCase().indexOf(fval) !== -1)) {
return false;
}
}
return true;
}) : this.data;
}; BootstrapTable.prototype.onColumnAdvancedSearch = function (event) {
var text = $.trim($(event.currentTarget).val());
var $field = $(event.currentTarget)[0].id; if ($.isEmptyObject(this.filterColumnsPartial)) {
this.filterColumnsPartial = {};
}
if (text) {
this.filterColumnsPartial[$field] = text;
} else {
delete this.filterColumnsPartial[$field];
} this.options.pageNumber = 1;
this.onSearch(event);
this.updatePagination();
this.trigger('column-advanced-search', $field, text);
}; }(jQuery);

配置bootstrap-table的js文件:

     $("#listTable").bootstrapTable({
columns:[
{
title: '序号',
align: 'center',
valign: 'bottom',
//field : 'id',
formatter:function(value,row,index){
return index+1;
}
},{
title: '客户ID',
align: 'center',
field: 'orgId',
visible: false
},{
title : '客户名称',
align : 'center',
field : 'orgName',
searchable : true
},{
title : '户号',
align : 'center',
field : 'account_num'
},{
title : '月份',
align : 'center',
field : 'ele_date' },{
title : '用电量需求(单位:兆瓦时)',
align : 'center',
field : 'ele_need_mount'
},{
title : '意向成交价差 (单位:元/兆瓦时)',
align : 'center',
field : 'intent_ele_price'
},{
title : '查看',
align : 'center',
field : 'fj'
}],
striped: true, //隔行变色
strictSearch: true,
clickToSelect: true,
cache:false,
showRefresh: true,
pagination: false,
pageNumber:1,
pageSize: 15,
pageList: [5, 10, 15, 20, 25],
showExport: true,//显示导出按钮
exportDataType: "basic",//导出类型
sidePagination: "client",
advancedSearch:true,//允许外部搜索 这个是扩充的js里面的属性
56 idTable:"abc",//搜索input的父级id
searchOnEnterKey:false,
strictSearch:false,
queryParamsType : "limit",
//search : true,
// searchText : "客户名称",
//toolbar: '#toolbar',
data:tableData
}); //search下面的内容除了选择器都是固定的
$("#listTable").on('post-body.bs.table', function () {
//debugger;
console.log($("#listTable").data);
var $search = $("#listTable").data('bootstrap.table').$toolbar.find('.search input');
$search.attr('placeholder', '客户名称');
$search.parents(".fixed-table-toolbar").css({position:'absolute',top: '-53px',right: '16px'});
}); });

对应的html页面是:

<div class="row">
<div class="ibox-title">
<h5>
<i class="fa fa-sitemap"></i> 月度交易结果分配详情列表 <span class='sfont'>(电量单位:兆瓦时
)</span>
</h5>
<div class="fright" style="margin-top: -8px;">
<button class="btn btn-w-m btn-primary editBtn" type="button" style="margin-right: 5px;"
id="edit_btn_input" ng-click="editOperater()">编辑</button>
<span class="tit_inputbox" id="abc"> <input type="text"      //这里的id值是abc 和bootstrap-table设置的需要一样
id="orgName" placeholder="客户名称" />
</span>
</div>
</div>
<div class="col-md-12 ibox-content">
<table
class="table table-striped table-bordered table-hover dataTables-example"
id="sitemap_table"></table>
</div>
</div>

bootstrap table 前端搜索的更多相关文章

  1. Bootstrap table前端分页(ssm版)

    说明bootstrap table可以前端分页,也可以后端sql用limit分页.前端分页下性能和意义都不大,故一般情况下不用这种,请看我的另一篇后端分页的博客源码下载地址:https://git.o ...

  2. BootStrap table 传递搜索参数

    看bootStrap table文档不难发现它有一个queryparams属性,是向后台传递参数的,默认参数已有pageSize.pageIndex等,那么怎么传递自定义的参数呢?在网上找了好多也没有 ...

  3. bootstrap table 插件 搜索

    以前用过easyui datagrid 每次搜索的时候调用datagrid构造方法 重新获取数据, 发现bootstrap-table 插件不行,只需要初始化一次, 以后每次搜索时,直接调用refre ...

  4. bootstrap table + spring + springmvc + mybatis 实现从前端到后端的表格分页

    1.使用准备 前台需要的资源文件,主要有Bootstrap3相关css.js以及bootstrap Table相关css.js: <-- 样式 --> <link rel=" ...

  5. js实现table中前端搜索(模糊查询)

    项目中用到js前端搜索功能,根据 姓名或姓名 进行 搜索,实现方法如下,遍历table所有行中的某列,符合条件则置tr为display:'',不满足条件置tr为display:none. 代码如下: ...

  6. [前端插件]Bootstrap Table服务器分页与在线编辑应用总结

    先看Bootstrap Table应用效果: 表格用来显示数据库中的数据,数据通过AJAX从服务器加载,同时分页功能有服务器实现,避免客户端分页,在加载大量数据时造成的用户体验不好.还可以设置查询数据 ...

  7. 轻量级表格插件Bootstrap Table。拥有强大的支持固定表头、单/复选、排序、分页、搜索及自定义表头等功能。

    Bootstrap Table是轻量级的和功能丰富的以表格的形式显示的数据,支持单选,复选框,排序,分页,显示/隐藏列,固定标题滚动表,响应式设计,Ajax加载JSON数据,点击排序的列,卡片视图等. ...

  8. 如何将自定义的搜索参数便捷的添加到js方式的bootstrap table的参数中

    页面: <div> <form id="exp_form"> 查询参数... <button type="button" oncl ...

  9. BootStrap table使用

    bootstrap table git address https://github.com/wenzhixin/bootstrap-table 引入文件 <link rel="sty ...

随机推荐

  1. linux网卡绑定脚本

    2013-08-20 15:30:51 此脚本适用于CentOS5.x和CentOS6.x. #!/bin/bash #**************************************** ...

  2. .net委托

    今天要学的是委托 委托的基本形式 直接上代码 public delegate int AddDelegate(int x,int y); class Program { static void Mai ...

  3. [翻译]Javaslang 介绍

    原文地址:Introduction to Javaslang 1. 概述 在这篇文章中,我们将会探讨: Javaslang 是什么? 为什么需要它? 以及怎样在项目中使用它? Javaslang 是J ...

  4. python httplib2应用get post

    import httplib2,time #装饰器方法,用于记录方法消耗时间 #推荐将print 改成log def timer(func):     def _warpper(self,*argv) ...

  5. 八大排序算法的Java代码实现

    简单插入排序 public class QuickSort { private static void quickSort(int [] a, int low, int high){ if (low ...

  6. Python编程笔记(第二篇)二进制、字符编码、数据类型

    一.二进制 bin() 在python中可以用bin()内置函数获取一个十进制的数的二进制 计算机容量单位 8bit = 1 bytes 字节,最小的存储单位,1bytes缩写为1B 1KB = 10 ...

  7. unity luaFramework

    1 AppConst: DebugMode: 调试模式,true:lua脚本直接读取自 AssetDir,false:开始会将AssetDir内的lua脚本复制到 Util.DataPath内(根据平 ...

  8. hibernate 的evict 和clear

    摘自百度知道:http://zhidao.baidu.com/question/63663640.html 问: 先创建一个Student,然后调用session.save方法,然后再调用evict方 ...

  9. java运行报错:nested exception is java.lang.NoSuchFieldError: INSTANCE,但使用@Test测试是好的

    解决方法: 原因是,在tomcat里,同名不同版本的jar包,默认加载版本低的.我项目里有两个httpclient jar包.一个4.2.5  另一个是4.5.所以加载了4.2.5的,而我要用的是4. ...

  10. FMS是什么?