Methods

The Methods API of Bootstrap Table.

The calling method syntax: $('#table').bootstrapTable('method', parameter).

append

  • Parameter: data

  • Detail:

    Append the data to table.

  • Example: Append

check

  • Parameter: index

  • Detail:

    Check a row, the row index start with 0.

  • Example: Check/Uncheck

checkAll

  • Parameter: undefined

  • Detail:

    Check all current page rows.

  • Example: Check/Uncheck All

checkBy

  • Parameter: params

  • Detail:

    Check a row by array of values, the params contain:

    • field: name of the field used to find records.
    • values: array of values for rows to check.
  • Example: Check/Uncheck By

checkInvert

  • Parameter: undefined

  • Detail:

    Invert check of current page rows. Triggers onCheckSome and onUncheckSome events.

  • Example: Check Invert

collapseAllRows

  • Parameter: undefined

  • Detail:

    Collapse all rows if the detail view option is set to true.

  • Example: Expand/Collapse All Rows

collapseRow

  • Parameter: index

  • Detail:

    Collapse the row that has the index passed by parameter if the detail view option is set to true.

  • Example: Expand/Collapse Row

collapseRowByUniqueId

  • Parameter: uniqueId

  • Detail:

    Collapse the row that has the uniqueId passed by parameter if the detail view option is set to true.

  • Example: Expand/Collapse Row by uniqueId

destroy

  • Parameter: undefined

  • Detail:

    Destroy the Bootstrap Table.

  • Example: Destroy

expandAllRows

  • Parameter: undefined

  • Detail:

    Expand all rows if the detail view option is set to true.

  • Example: Expand/Collapse All Rows

expandRow

  • Parameter: index

  • Detail:

    Expand the row that has the index passed by parameter if the detail view option is set to true.

  • Example: Expand/Collapse Row

expandRowByUniqueId

  • Parameter: uniqueId

  • Detail:

    Expand the row that has the uniqueId passed by parameter if the detail view option is set to true.

  • Example: Expand/Collapse Row by uniqueId

filterBy

  • Parameter:
    • filter - An Object of filter Default: {}
    • options - An Object of options Default:
        {
            'filterAlgorithm': 'and'
        }
      
  • Detail:

    (Can use only in client-side) Filter data in table. There are multiple ways to filter:

    • Leave the options blank to use the and filter.
    • Set the filterAlgorithm (see at parameter) to or to use the or filter.
    • Pass a function to the filterAlgorithm (see at parameter) to use a custom filter.

    Filter Algorithm

    • And
      • Filter {age: 10} to show the data only age is equal to 10. You can also filter with an array of values, as in: {age: 10, hairColor: ['blue', 'red', 'green']} to find data where age is equal to 10 and hairColor is either blue, red, or green.
    • Or
      • Filter {age: 10, name: "santa"} to show all Data which has a age of 10 or the name is equals to santa.
    • Custom
      • Filter by your Custom algorithm
      • Function parameters:
        • Row
        • Filters
      • Return true to keep the row and return false to filter the row.
  • Example: Filter By

getAllSelections

  • Parameter: undefined

  • Detail:

    Return all selected rows contain search or filter, when no record selected, an empty array will return.

  • Example: Get All Selections

getData

  • Parameter: params

  • Detail:

    Get the loaded data of table at the moment that this method is called

    • useCurrentPage: if set to true the method will return the data only in the current page.
    • includeHiddenRows: if set to true the method will include the hidden rows.
    • unfiltered: if set to true the method will include all data (unfiltered).
    • formatted: get the formatted value from the defined formatter.
  • Example: Get Data

getHiddenColumns

getHiddenRows

  • Parameter: show

  • Detail:

    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.

  • Example: Get Hidden Rows

getOptions

  • Parameter: undefined

  • Detail:

    Return the options object.

  • Example: Get Options

getRowByUniqueId

  • Parameter: id

  • Detail:

    Get data from table, the row that contains the id passed by parameter.

  • Example: Get Row By Unique Id

getScrollPosition

  • Parameter: undefined

  • Detail:

    Get the current scroll position, the unit is 'px'.

  • Example: Get Scroll Position

getSelections

  • Parameter: undefined

  • Detail:

    Return selected rows, when no record selected, an empty array will return.

  • Example: Get Selections

getVisibleColumns

hideAllColumns

hideColumn

  • Parameter: field

  • Detail:

    Hide the specified field column. The parameter can be a string or a array of fields.

  • Example: Show/Hide Column

hideLoading

hideRow

  • Parameter: params

  • Detail:

    Hide the specified row. The params must contain at least one of the following properties:

    • index: the row index.
    • uniqueId: the value of the uniqueId for that row.
  • Example: Show/Hide Row

insertRow

  • Parameter: params

  • Detail:

    Insert a new row, the params contain following properties:

    • index: the row index to insert into.
    • row: the row data.
  • Example: Insert Row

load

  • Parameter: data

  • Detail:

    Load the data to table, the old rows will be removed.

  • Example: Load

mergeCells

  • Parameter: params

  • Detail:

    Merge some cells to one cell, the params contain following properties:

    • index: the row index.
    • field: the field name.
    • rowspan: the rowspan count to be merged.
    • colspan: the colspan count to be merged.
  • Example: Merge Cells

nextPage

prepend

  • Parameter: data

  • Detail:

    Prepend the data to table.

  • Example: Prepend

prevPage

refresh

  • Parameter: params

  • Detail:

    Refresh/reload the remote server data, you can set {silent: true} to refresh the data silently, and set {url: newUrl, pageNumber: pageNumber, pageSize: pageSize} to change the url (optional), page number (optional) and page size (optional). To supply query params specific to this request, set {query: {foo: 'bar'}}.

  • Example: Refresh

refreshOptions

  • Parameter: options

  • Detail:

    Refresh the table options.

  • Example: Refresh Options

remove

  • Parameter: params

  • Detail:

    Remove data from table, the params contain two properties:

    • field: the field name of remove rows. If $index is not in your fields, you can use this special field $index to remove rows by row index.
    • values: the array of values for rows which should be removed. If you use the special field $index, you can pass an array of indexes.
  • Example: Remove

removeAll

  • Parameter: undefined

  • Detail:

    Remove all data from table.

  • Example: Remove All

removeByUniqueId

  • Parameter: id

  • Detail:

    Remove data from table, the row that contains the id passed by parameter.

  • Example: Remove By Unique Id

resetSearch

  • Parameter: text

  • Detail:

    Set the search text.

  • Example: Reset Search

resetView

  • Parameter: params

  • Detail:

    Reset the Bootstrap Table view, for example reset the table height, the params contain:

    • height: the height of the table.
  • Example: Reset View

scrollTo

  • Parameter: value|object

  • Detail:

    • value
      • Scroll to the number value position, the unit is 'px', set 'bottom' means scroll to the bottom.
    • object
      • Scroll to the unit (px or rows (index starts by 0)) Default: {unit: 'px', value: 0}
  • Example: Scroll To

selectPage

showAllColumns

showColumn

  • Parameter: field

  • Detail:

    Show the specified field column. The parameter can be a string or a array of fields.

  • Example: Show/Hide Column

showLoading

showRow

  • Parameter: params

  • Detail:

    Show the specified row. The params must contain at least one of the following properties:

    • index: the row index.
    • uniqueId: the value of the uniqueId for that row.
  • Example: Show/Hide Row

toggleDetailView

  • Parameter: index

  • Detail:

    Toggle the row that has the index passed by parameter if the detail view option is set to true.

  • Example: Toggle Detail View

toggleFullscreen

togglePagination

  • Parameter: undefined

  • Detail:

    Toggle the pagination option.

  • Example: Toggle Pagination

toggleView

  • Parameter: undefined

  • Detail:

    Toggle the card/table view.

  • Example: Toggle View

uncheck

  • Parameter: index

  • Detail:

    Uncheck a row, the row index start with 0.

  • Example: Check/Uncheck

uncheckAll

  • Parameter: undefined

  • Detail:

    Uncheck all current page rows.

  • Example: Check/Uncheck All

uncheckBy

  • Parameter: params

  • Detail:

    Uncheck a row by array of values, the params contain:

    • field: name of the field used to find records.
    • values: array of values for rows to uncheck.
  • Example: Check/Uncheck By

updateByUniqueId

  • Parameter: params

  • Detail:

    Update the specified row(s), each params contain following properties:

    • id: a row id where the id should be the uniqueId field assigned to the table.
    • row: the new row data.
    • replace (optional): set to true to replace the row instead of extending.
  • Example: Update By Unique Id

updateCell

  • Parameter: params

  • Detail:

    Update one cell, the params contain following properties:

    • index: the row index.
    • field: the field name.
    • value: the new field value.

    To disable table re-initialization you can set {reinit: false}.

  • Example: Update Cell

updateCellByUniqueId

  • Parameter: params

  • Detail:

    Update the specified cell(s), each params contain following properties:

    • id: row id where the id should be the uniqueId field assigned to the table.
    • field: field name of the cell to be updated.
    • value: new value of the cell.
  • Example: Update Cell By Unique Id

updateColumnTitle

  • Parameter: params

  • Detail:

    Update the field title of column, the params contain following properties:

    • field: the field name.
    • title: the field title.
  • Example: Update Column Title

updateFormatText

  • Parameter: formatName, text

  • Detail:

    Update the localizations format text.

  • Example: Update Format Text

    updateRow

  • Parameter: params

  • Detail:

    Update the specified row(s), each params contain following properties:

    • index: the row index to be updated.
    • row: the new row data.
    • replace (optional): set to true to replace the row instead of extending.
  • Example: Update Row