文档包含了表格属性、列属性、事件、方法等等。

表格参数

表格的参数定义在 jQuery.fn.bootstrapTable.defaults

名称
 
标签
 
类型
 
默认
 
描述
 
- data-toggle String 'table' 不用写 JavaScript 直接启用表格。
classes data-classes String 'table table-hover' 表格的类名称。默认情况下,表格是有边框的,你可以添加 'table-no-bordered' 来删除表格的边框样式。
sortClass data-sort-class String undefined The class name of the td elements which are sorted.
height data-height Number undefined 定义表格的高度。
undefinedText data-undefined-text String '-' 当数据为 undefined 时显示的字符
striped data-striped Boolean false 设置为 true 会有隔行变色效果
sortName data-sort-name String undefined 定义排序列,通过url方式获取数据填写字段名,否则填写下标
sortOrder data-sort-order String 'asc' 定义排序方式 'asc' 或者 'desc'
sortStable data-sort-stable Boolean false 设置为 true 将获得稳定的排序,我们会添加_position属性到 row 数据中。
iconsPrefix data-icons-prefix String 'glyphicon' 定义字体库 ('Glyphicon' or 'fa' for FontAwesome),使用"fa"时需引用 FontAwesome,并且配合 icons 属性实现效果
Glyphicon 集成于Bootstrap可免费使用 参考:http://glyphicons.com/
FontAwesome 参考:http://fortawesome.github.io/
icons data-icons Object {
  paginationSwitchDown: 'glyphicon-collapse-down icon-chevron-down',
  paginationSwitchUp: 'glyphicon-collapse-up icon-chevron-up',
  refresh: 'glyphicon-refresh icon-refresh'
  toggle: 'glyphicon-list-alt icon-list-alt'
  columns: 'glyphicon-th icon-th'
  detailOpen: 'glyphicon-plus icon-plus'
  detailClose: 'glyphicon-minus icon-minus'
}
自定义图标
columns - Array [] 列配置项,详情请查看 列参数 表格.
data - Array [] 加载json格式的数据
ajax data-ajax Function undefined 自定义 AJAX 方法,须实现 jQuery AJAX API
method data-method String 'get' 服务器数据的请求方式 'get' or 'post'
url data-url String undefined 服务器数据的加载地址
cache data-cache Boolean true 设置为 true 禁用 AJAX 数据缓存
contentType data-content-type String 'application/json' 发送到服务器的数据编码类型
dataType data-data-type String 'json' 服务器返回的数据类型
ajaxOptions data-ajax-options Object {} 提交ajax请求时的附加参数,可用参数列请查看http://api.jquery.com/jQuery.ajax.
queryParams data-query-params Function function(params) {
return params;
}
请求服务器数据时,你可以通过重写参数的方式添加一些额外的参数,例如 toolbar 中的参数 如果 queryParamsType = 'limit' ,返回参数必须包含
limit, offset, search, sort, order 否则, 需要包含: 
pageSize, pageNumber, searchText, sortName, sortOrder. 
返回false将会终止请求
queryParamsType data-query-params-type String 'limit' 设置为 'limit' 则会发送符合 RESTFul 格式的参数.
responseHandler data-response-handler Function function(res) {
return res;
}
加载服务器数据之前的处理程序,可以用来格式化数据。
参数:res为从服务器请求到的数据。
pagination data-pagination Boolean false 设置为 true 会在表格底部显示分页条
paginationLoop data-pagination-loop Boolean true 设置为 true 启用分页条无限循环的功能。
onlyInfoPagination data-only-info-pagination Boolean false 设置为 true 只显示总数据数,而不显示分页按钮。需要 pagination='True'
sidePagination data-side-pagination String 'client' 设置在哪里进行分页,可选值为 'client' 或者 'server'。设置 'server'时,必须设置 服务器数据地址(url)或者重写ajax方法
pageNumber data-page-number Number 1 如果设置了分页,首页页码
pageSize data-page-size Number 10 如果设置了分页,页面数据条数
pageList data-page-list Array [10, 25, 50, 100, All] 如果设置了分页,设置可供选择的页面数据条数。设置为All 则显示所有记录。
selectItemName data-select-item-name String 'btSelectItem' radio or checkbox 的字段名
smartDisplay data-smart-display Boolean true True to display pagination or card view smartly.
escape data-escape Boolean false 转义HTML字符串,替换 &<>"`, 和 ' 字符.
search data-search Boolean false 是否启用搜索框
searchOnEnterKey data-search-on-enter-key Boolean false 设置为 true时,按回车触发搜索方法,否则自动触发搜索方法
strictSearch data-strict-search Boolean false 设置为 true启用 全匹配搜索,否则为模糊搜索
searchText data-search-text String '' 初始化搜索文字
searchTimeOut data-search-time-out Number 500 设置搜索超时时间
trimOnSearch data-trim-on-search Boolean true 设置为 true 将允许空字符搜索
showHeader data-show-header Boolean true 是否显示列头
showFooter data-show-footer Boolean false 是否显示列脚
showColumns data-show-columns Boolean false 是否显示 内容列下拉框
showRefresh data-show-refresh Boolean false 是否显示 刷新按钮
showToggle data-show-toggle Boolean false 是否显示 切换试图(table/card)按钮
showPaginationSwitch data-show-pagination-switch Boolean false 是否显示 数据条数选择框
minimumCountColumns data-minimum-count-columns Number 1 当列数小于此值时,将隐藏内容列下拉框。
idField data-id-field String undefined 指定主键列
uniqueId data-unique-id String undefined Indicate an unique identifier for each row.
cardView data-card-view Boolean false 设置为 true将显示card视图,适用于移动设备。否则为table试图,适用于pc
detailView data-detail-view Boolean false 设置为 true 可以显示详细页面模式。
detailFormatter data-detail-formatter Function function(index, row) {
return '';
}
格式化详细页面模式的视图。
searchAlign data-search-align String 'right' 指定 搜索框 水平方向的位置。'left' or 'right'
buttonsAlign data-buttons-align String 'right' 指定 按钮 水平方向的位置。'left' or 'right'
toolbarAlign data-toolbar-align String 'left' 指定 toolbar 水平方向的位置。'left' or 'right'
paginationVAlign data-pagination-v-align String 'bottom' 指定 分页条 在垂直方向的位置。'top' or 'bottom' or 'bonth'
paginationHAlign data-pagination-h-align String 'right' 指定 分页条 在水平方向的位置。'left' or 'right'
paginationDetailHAlign data-pagination-detail-h-align String 'left' 指定 分页详细信息 在水平方向的位置。'left' or 'right'
paginationPreText data-pagination-pre-text String '<' 指定分页条中上一页按钮的图标或文字
paginationNextText data-pagination-next-text String '>' 指定分页条中下一页按钮的图标或文字
clickToSelect data-click-to-select Boolean false 设置true 将在点击行时,自动选择rediobox 和 checkbox
singleSelect data-single-select Boolean false 设置True 将禁止多选
toolbar data-toolbar String undefined 一个jQuery 选择器,指明自定义的toolbar 例如:
#toolbar, .toolbar.
checkboxHeader data-checkbox-header Boolean true 设置false 将在列头隐藏check-all checkbox .
maintainSelected data-maintain-selected Boolean false 设置为 true 在点击分页按钮或搜索按钮时,将记住checkbox的选择项
sortable data-sortable Boolean true 设置为false 将禁止所有列的排序
silentSort data-silent-sort Boolean true 设置为 false 将在点击分页按钮时,自动记住排序项。仅在 sidePagination设置为 server时生效.
rowStyle data-row-style Function function(row,index) {
return class;
}
自定义行样式 参数为:
row: 行数据
index: 行下标
返回值可以为class或者css
rowAttributes data-row-attributes Function function(row,index) {
return attributes;
}
自定义行属性 参数为:
row: 行数据
index: 行下标
返回值可以为class或者css 支持所有自定义属性
customSearch data-custom-search Function $.noop The custom search function is executed instead of built-in search function, takes one parameters: 
text: the search text.
Example usage:

            function customSearch(text) {
//Search logic here.
//You must use `this.data` array in order to filter the data. NO use `this.options.data`.
}
customSort data-custom-sort Function $.noop The custom sort function is executed instead of built-in sort function, takes two parameters: 
sortName: the sort name.
sortOrder: the sort order.
Example usage:

            function customSort(sortName, sortOrder) {
//Sort logic here.
//You must use `this.data` array in order to sort the data. NO use `this.options.data`.
}

列参数

The column options is defined in jQuery.fn.bootstrapTable.columnDefaults.

Name
 
Attribute
 
Type
 
Default
 
Description
 
radio data-radio Boolean false True to show a radio. The radio column has fixed width.
checkbox data-checkbox Boolean false True to show a checkbox. The checkbox column has fixed width.
field data-field String undefined The column field name.
title data-title String undefined The column title text.
titleTooltip data-title-tooltip String undefined The column title tooltip text. This option also support the title HTML attribute
class class / data-class String undefined The column class name.
rowspan rowspan / data-rowspan Number undefined Indicate how many rows a cell should take up.
colspan colspan / data-colspan Number undefined Indicate how many columns a cell should take up.
align data-align String undefined Indicate how to align the column data. 'left', 'right', 'center' can be used.
halign data-halign String undefined Indicate how to align the table header. 'left', 'right', 'center' can be used.
falign data-falign String undefined Indicate how to align the table footer. 'left', 'right', 'center' can be used.
valign data-valign String undefined Indicate how to align the cell data. 'top', 'middle', 'bottom' can be used.
width data-width Number {Pixels or Percentage} undefined The width of column. If not defined, the width will auto expand to fit its contents. Also you can add '%' to your number and the bootstrapTable will use the percentage unit, otherwise, you can add or no the 'px' to your number and then the bootstrapTable will use the pixels
sortable data-sortable Boolean false True to allow the column can be sorted.
order data-order String 'asc' The default sort order, can only be 'asc' or 'desc'.
visible data-visible Boolean true False to hide the columns item.
cardVisible data-card-visible Boolean true False to hide the columns item in card view state.
switchable data-switchable Boolean true False to disable the switchable of columns item.
clickToSelect data-click-to-select Boolean true True to select checkbox or radiobox when the column is clicked.
formatter data-formatter Function undefined The context (this) is the column Object. 
The cell formatter function, take three parameters: 
value: the field value. 
row: the row record data.
index: the row index.
footerFormatter data-footer-formatter Function undefined The context (this) is the column Object. 
The function, take one parameter: 
data: Array of all the data rows. 
the function should return a string with the text to show in the footer cell.
events data-events Object undefined The cell events listener when you use formatter function, take three parameters: 
event: the jQuery event. 
value: the field value. 
row: the row record data.
index: the row index.
sorter data-sorter Function undefined The custom field sort function that used to do local sorting, take two parameters: 
a: the first field value.
b: the second field value.
sortName data-sort-name String undefined Provide a customizable sort-name, not the default sort-name in the header, or the field name of the column. For example, a column might display the value of fieldName of "html" such as "<b><span style="color:red">abc</span></b>", but a fieldName to sort is "content" with the value of "abc".
cellStyle data-cell-style Function undefined The cell style formatter function, take three parameters: 
value: the field value.
row: the row record data.
index: the row index.
field: the row field.
Support classes or css.
searchable data-searchable Boolean true True to search data for this column.
searchFormatter data-search-formatter Boolean true True to search use formated data.

事件

Option 事件
 
jQuery 事件
 
参数
 
描述
 
onAll all.bs.table name, args 所有的事件都会触发该事件,参数包括:
name:事件名,
args:事件的参数。
onClickRow click-row.bs.table row, $element 当用户点击某一行的时候触发,参数包括:
row:点击行的数据,
$element:tr 元素,
field:点击列的 field 名称。
onDblClickRow dbl-click-row.bs.table row, $element 当用户双击某一行的时候触发,参数包括:
row:点击行的数据,
$element:tr 元素,
field:点击列的 field 名称。
onClickCell click-cell.bs.table field, value, row, $element 当用户点击某一列的时候触发,参数包括:
field:点击列的 field 名称,
value:点击列的 value 值,
row:点击列的整行数据,
$element:td 元素。
onDblClickCell dbl-click-cell.bs.table field, value, row, $element 当用户双击某一列的时候触发,参数包括:
field:点击列的 field 名称,
value:点击列的 value 值,
row:点击列的整行数据,
$element:td 元素。
onSort sort.bs.table name, order Fires when user sort a column, the parameters contains: 
name: the sort column field name
order: the sort column order.
onCheck check.bs.table row Fires when user check a row, the parameters contains: 
row: the record corresponding to the clicked row. $element: the DOM element checked.
onUncheck uncheck.bs.table row Fires when user uncheck a row, the parameters contains: 
row: the record corresponding to the clicked row. $element: the DOM element unchecked.
onCheckAll check-all.bs.table rows Fires when user check all rows, the parameters contains: 
rows: array of records corresponding to newly checked rows.
onUncheckAll uncheck-all.bs.table rows Fires when user uncheck all rows, the parameters contains: 
rows: array of records corresponding to previously checked rows.
onCheckSome check-some.bs.table rows Fires when user check some rows, the parameters contains: 
rows: array of records corresponding to previously checked rows.
onUncheckSome uncheck-some.bs.table rows Fires when user uncheck some rows, the parameters contains: 
rows: array of records corresponding to previously checked rows.
onLoadSuccess load-success.bs.table data Fires when remote data is loaded successfully.
onLoadError load-error.bs.table status Fires when some errors occur to load remote data.
onColumnSwitch column-switch.bs.table field, checked Fires when switch the column visible.
onColumnSearch column-search.bs.table field, text Fires when search by column.
onPageChange page-change.bs.table number, size Fires when change the page number or page size.
onSearch search.bs.table text Fires when search the table.
onToggle toggle.bs.table cardView Fires when toggle the view of table.
onPreBody pre-body.bs.table data Fires before the table body is rendered
onPostBody post-body.bs.table none Fires after the table body is rendered and available in the DOM
onPostHeader post-header.bs.table none Fires after the table header is rendered and availble in the DOM
onExpandRow expand-row.bs.table index, row, $detail 当点击详细图标展开详细页面的时候触发。
onCollapseRow collapse-row.bs.table index, row 当点击详细图片收起详细页面的时候触发。
onRefreshOptions refresh-options.bs.table options Fires after refresh the options and before destroy and init the table.
onRefresh refresh.bs.table params Fires after the click the refresh button.

方法

使用方法的语法:$('#table').bootstrapTable('method', parameter);

名称
 
参数
 
描述
 
例子
 
getOptions none 返回表格的 Options。  
getSelections none 返回所选的行,当没有选择任何行的时候返回一个空数组。  
getAllSelections none 返回所有选择的行,包括搜索过滤前的,当没有选择任何行的时候返回一个空数组。  
getData useCurrentPage 或者当前加载的数据。假如设置 useCurrentPage 为 true,则返回当前页的数据。  
getRowByUniqueId id 根据 uniqueId 获取行数据。  
load data 加载数据到表格中,旧数据会被替换。  
showAllColumns none Show All the columns.  
hideAllColumns none Hide All the columns.  
append data 添加数据到表格在现有数据之后。  
prepend data 插入数据到表格在现有数据之前。  
remove params 从表格中删除数据,包括两个参数: field: 需要删除的行的 field 名称。
values: 需要删除的行的值,类型为数组。
 
removeAll - 删除表格所有数据。  
removeByUniqueId id 根据 uniqueId 删除指定的行。  
insertRow params 插入新行,参数包括:
index: 要插入的行的 index。
row: 行的数据,Object 对象。
 
updateRow params 更新指定的行,参数包括:
index: 要更新的行的 index。
row: 行的数据,Object 对象。
 
showRow params 显示指定的行,参数包括:
index: 要更新的行的 index 或者 uniqueId。
isIdField: 指定 index 是否为 uniqueid。
 
hideRow params 显示指定的行,参数包括:
index: 要更新的行的 index。
uniqueId: 或者要更新的行的 uniqueid。
 
getRowsHidden show Get all rows hidden and if you pass the show parameter true the rows will be shown again, otherwise, the method only will return the rows hidden.
mergeCells options Merge some cells to one cell, the options contains following properties: 
index: the row index. 
field: the field name.
rowspan: the rowspan count to be merged. 
colspan: the colspan count to be merged.
updateCell params Update one cell, the params contains following properties: 
index: the row index. 
field: the field name.
value: the new field value.
refresh params Refresh the remote server data, you can set {silent: true} to refresh the data silently, and set {url: newUrl} to change the url. To supply query params specific to this request, set {query: {foo: 'bar'}}
refreshOptions options Refresh the options
resetSearch text Set the search text
showLoading none Show loading status.
hideLoading none Hide loading status.
checkAll none Check all current page rows.
uncheckAll none Uncheck all current page rows.
check index Check a row, the row index start with 0.
uncheck index Uncheck a row, the row index start with 0.
checkBy params Check a row by array of values, the params contains:
field: name of the field used to find records
values: array of values for rows to check
Example: 
$("#table").bootstrapTable("checkBy", {field:"field_name", values:["value1","value2","value3"]})
uncheckBy params Uncheck a row by array of values, the params contains:
field: name of the field used to find records
values: array of values for rows to uncheck
Example: 
$("#table").bootstrapTable("uncheckBy", {field:"field_name", values:["value1","value2","value3"]})
resetView params Reset the bootstrap table view, for example reset the table height.
resetWidth none Resizes header and footer to fit current columns width
destroy none Destroy the bootstrap table.
showColumn field Show the specified column.
hideColumn field Hide the specified column.
getHiddenColumns - 获取隐藏的列。
getVisibleColumns - 获取可见列。
scrollTo value 滚动到指定位置,单位为 px,设置 'bottom' 表示跳到最后。
getScrollPosition none 获取当前滚动条的位置,单位为 px。
filterBy params (只能用于 client 端)过滤表格数据, 你可以通过过滤{age: 10}来显示 age 等于 10 的数据。
selectPage page 跳到指定的页。
prevPage none 跳到上一页。
nextPage none 跳到下一页。
togglePagination none 切换分页选项。
toggleView none 切换 card/table 视图
expandRow index Expand the row that has the index passed by parameter if the detail view option is set to True.
collapseRow index Collapse the row that has the index passed by parameter if the detail view option is set to True.
expandAllRows is subtable Expand all rows if the detail view option is set to True.
collapseAllRows is subtable Collapse all rows if the detail view option is set to True.

多语言

Name
 
Parameter
 
Default
 
formatLoadingMessage - 'Loading, please wait…'
formatRecordsPerPage pageNumber '%s records per page'
formatShowingRows pageFrom, pageTo, totalRows 'Showing %s to %s of %s rows'
formatDetailPagination totalRows 'Showing %s rows'
formatSearch - 'Search'
formatNoMatches - 'No matching records found'
formatRefresh - 'Refresh'
formatToggle - 'Toggle'
formatColumns - 'Columns'
formatAllRows - 'All'

PS:

We can import all locale files what you need:

<script src="bootstrap-table-en-US.js"></script>
<script src="bootstrap-table-zh-CN.js"></script>
...

And then use JavaScript to switch locale:

$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['en-US']);
// $.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales['zh-CN']);
// ... 转:http://bootstrap-table.wenzhixin.net.cn/zh-cn/

BootStrapTable 文档的更多相关文章

  1. bootstraptable插件文档的坑

    1.事件onCheck中文档参数为row, $element正确的顺序为$element,row eg: $Table.on('check.bs.table', function ($element, ...

  2. 基于Metronic的Bootstrap开发框架经验总结(17)-- 使用 summernote插件实现HTML文档的编辑和图片插入操作

    在很多场合,我们需要在线编辑HTML内容,然后在页面上或者其他终端上(如小程序.APP应用等)显示,编辑HTML内容的插件有很多,本篇介绍基于Bootstrap的 summernote插件实现HTML ...

  3. C#给PDF文档添加文本和图片页眉

    页眉常用于显示文档的附加信息,我们可以在页眉中插入文本或者图形,例如,页码.日期.公司徽标.文档标题.文件名或作者名等等.那么我们如何以编程的方式添加页眉呢?今天,这篇文章向大家分享如何使用了免费组件 ...

  4. dotNET跨平台相关文档整理

    一直在从事C#开发的相关技术工作,从C# 1.0一路用到现在的C# 6.0, 通常情况下被局限于Windows平台,Mono项目把我们C#程序带到了Windows之外的平台,在工作之余花了很多时间在M ...

  5. ABP文档 - Javascript Api - AJAX

    本节内容: AJAX操作相关问题 ABP的方式 AJAX 返回信息 处理错误 HTTP 状态码 WrapResult和DontWrapResult特性 Asp.net Mvc 控制器 Asp.net ...

  6. ABP文档 - EntityFramework 集成

    文档目录 本节内容: Nuget 包 DbContext 仓储 默认仓储 自定义仓储 特定的仓储基类 自定义仓储示例 仓储最佳实践 ABP可使用任何ORM框架,它已经内置了EntityFrame(以下 ...

  7. ABP文档 - SignalR 集成

    文档目录 本节内容: 简介 安装 服务端 客户端 连接确立 内置功能 通知 在线客户端 帕斯卡 vs 骆峰式 你的SignalR代码 简介 使用Abp.Web.SignalR nuget包,使基于应用 ...

  8. ABP文档 - 通知系统

    文档目录 本节内容: 简介 发送模式 通知类型 通知数据 通知重要性 关于通知持久化 订阅通知 发布通知 用户通知管理器 实时通知 客户端 通知存储 通知定义 简介 通知用来告知用户系统里特定的事件发 ...

  9. ABP文档 - Hangfire 集成

    文档目录 本节内容: 简介 集成 Hangfire 面板授权 简介 Hangfire是一个综合的后台作业管理器,可以在ABP里集成它替代默认的后台作业管理器,你可以为Hangfire使用相同的后台作业 ...

随机推荐

  1. MATLAB 的unique函数——数组矩阵的唯一值

    MATLAB 的unique函数——求数组矩阵的唯一值 相关MathWork文档见此:unique数组中的唯一值 1.C = unique(A) 返回与 A 中相同的数据,但是不包含重复项.C 已按照 ...

  2. JavaScript Window History 浏览器的历史

    window.history 对象在编写时可不使用 window 这个前缀. 为了保护用户隐私,对 JavaScript 访问该对象的方法做出了限制. 一些方法: history.back() - 与 ...

  3. linux RPM包安装、更新、删除等操作命令简明总结, 如何查看yum安装的软件路径 ?

    rpm -ivh package.rpm 安装一个rpm包rpm -ivh --nodeeps package.rpm 安装一个rpm包而忽略依赖关系警告rpm -U package.rpm 更新一个 ...

  4. Elasticstack 5.1.2 集群日志系统部署及实践

    Elasticstack 5.1.2 集群日志系统部署及实践 一.ELK Stack简介 ELK Stack 是Elasticsearch.Logstash.Kibana三个开源软件的组合,在实时数据 ...

  5. MySQL导入SQL文件过大或连接超时的解决办法/在navcat执行sql卡在0%

    set global max_allowed_packet=100 000 000;set global net_buffer_length=100000;SET GLOBAL  interactiv ...

  6. 【exe4j】如何利用exe4j把java桌面程序生成exe文件

    前言: 我们都知道Java可以将二进制程序打包成可执行jar文件,双击这个jar和双击exe效果是一样一样的,但感觉还是不同.其实将java程序打包成exe也需要这个可执行jar文件. 准备: ecl ...

  7. 【jsp】JSP中page指令isThreadSafe

    <%@ page isThreadSafe="true|false" %> 默认值为true isThreadSafe=false模式表示它是以Singleton模式运 ...

  8. MySQL USING 和 HAVING 用法

    USING 用于表连接时给定连接条件(可以理解为简写形式),如 SELECT * FROM table1 JOIN table2 ON table1.id = table2.id   使用 USING ...

  9. error nr.1045 access denied for user 'root'@'localhost' (using passwd:no)

    在windows上卸载了mysql,再次重新安装的时候运行失败,并报以下错误: 解决办法: 1.服务里面停止Mysql服务. 2.卸载Mysql,删除MySQL的安装目录. 3.此外还要删除以下目录的 ...

  10. .net core下直接执行SQL语句并生成DataTable

    .net core可以执行SQL语句,但是只能生成强类型的返回结果.例如var blogs = context.Blogs.FromSql("SELECT * FROM dbo.Blogs& ...