# 方法 []({{ site.repo }}/blob/master/docs/_i18n/{{ site.lang }}/documentation/methods.md) --- 使用方法的语法:`$('#table').bootstrapTable('method', parameter);`。
名称 | 参数 | 描述 | 例子 |
---|---|---|---|
getOptions | none | 返回表格的 Options。 | getOptions |
getSelections | none | 返回所选的行,当没有选择任何行的时候返回一个空数组。 | getSelections |
getAllSelections | none | 返回所有选择的行,包括搜索过滤前的,当没有选择任何行的时候返回一个空数组。 | getAllSelections |
getData | useCurrentPage | 或者当前加载的数据。假如设置 useCurrentPage 为 true,则返回当前页的数据。 | getData |
getRowByUniqueId | id | 根据 uniqueId 获取行数据。 | getRowByUniqueId |
load | data | 加载数据到表格中,旧数据会被替换。 | load |
append | data | 添加数据到表格在现有数据之后。 | append |
prepend | data | 插入数据到表格在现有数据之前。 | prepend |
remove | params |
从表格中删除数据,包括两个参数:
field: 需要删除的行的 field 名称。 values: 需要删除的行的值,类型为数组。 |
remove |
removeAll | - | 删除表格所有数据。 | removeAll |
removeByUniqueId | id | 根据 uniqueId 删除指定的行。 | removeByUniqueId |
insertRow | params |
插入新行,参数包括: index: 要插入的行的 index。 row: 行的数据,Object 对象。 |
insertRow |
updateRow | params |
更新指定的行,参数包括: index: 要更新的行的 index。 row: 行的数据,Object 对象。 |
updateRow |
showRow | params | 显示指定的行,参数包括: index: 要更新的行的 index 或者 uniqueId。 isIdField: 指定 index 是否为 uniqueid。 |
showRow-hideRow |
hideRow | params | 显示指定的行,参数包括: index: 要更新的行的 index。 uniqueId: 或者要更新的行的 uniqueid。 | showRow-hideRow |
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 | |
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 | - | 获取隐藏的列。 | |
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. |