Home > Web Front-end > Bootstrap Tutorial > Bootstrap Table API Chinese version (translation document)

Bootstrap Table API Chinese version (translation document)

angryTom
Release: 2020-05-15 09:18:27
Original
6593 people have browsed it

Bootstrap Table API Chinese version (translation document)

I saw that there are Chinese versions online, but some of them are literal translations, and some are not translated, so I plan to translate them again myself, and I will try my best to combine each one. Translate as much information as possible. If you find that the translated content is more than English, add a more detailed description. The name, attributes, types, and default values ​​of the table will not be translated. For example: "class", "id", etc. will not be translated. Please report any mistakes and they will be corrected in time, thank you.

Recommended tutorial: bootstrap tutorial

##1. "Name" can be written in $('# table').bootstrapTable({});, you can define some desired values, such as:

$("#realTime_Table").bootstrapTable({
		       search: true,
	            pagination: false,
	            pageSize: 15,
	            pageList: [5, 10, 15, 20],
	            showColumns: true,
	            showRefresh: false,
	            showToggle: true,
	            locale: "zh-CN",
	            striped: true
        });
Copy after login

2. "Attributes" are placed in the declaration table, such as :

<!--例子应该很好看懂Table options和Column options 所放的位置不同,随便写的,主要为了懂得如何用--!>

 <table id="realTime_Table" data-click-to-select="true" class="table table-bordered" data-page-size="20">
      <thead>
          <tr >
              <th data-sortable="true" data-field="realTimeDate">日期</th>
              <th data-sortable="true" data-field="newPlayerNum">新增用户</th>
              <th data-sortable="true" data-field="activePlayerNum">活跃用户</th>
          </tr>
      </thead>
      <tbody>
      </tbody>
</table>
Copy after login

3. If the name and attribute function are similar, then any place is enough. There is no need to repeat the definition. Some attributes are written in js rather than the name in the statement. The table is simpler, or vice verse (some attributes must be written, the corresponding name just indicates whether to enable that attribute)


The items of the table (Table options)

Defined in jQuery.fn.bootstrapTable.defaults file

##columns-Array[]The default empty array is defined in JS, field is the data-field, title is the header name of each column, etc. data-Array[ ]The loaded data. dataFielddata-data-fieldStringrows - In the name, write the field name of each column defined by yourself, that is, key, through Key can assign a value to a column of a row. ajaxdata-ajaxFunctionundefined - ajax method, similar to jQuery's ajax method##searchdata-searchBooleanfalse The default false does not display the search box in the upper right corner of the table. It can be set to true. As long as you enter content in the search box, the search will start.searchOnEnterKeydata-search-on- enter-keyBooleanfalseThe default false is not enabled, set to true to enable it, the function is compared with the above, enter the content in the search box and press Press the Enter key to start searchingstrictSearchdata-strict-searchBooleanfalse Set to true to enable precise searchsearchTextdata-search-textString"" Prerequisite: search is set to true and the search function is enabled. searchTimeOutdata- search-time-outNumber500Prerequisite: search is set to true and the search function is enabled.
NameAttributeTypeDefault valueFunction description
-data-toggleStringtable Just introduce the jquery, bootstrap, bootstrap-table packages, no need to add them in js You can use
if defined inside.By default, data-toggle="table" is written. You should know the data-toggle. Commonly used ones include "tooltip, popover, etc.", which I won't go into here.
classesdata-classesStringtable table-hoverThe class attribute of the table, if not defined by yourself, has a border by default, and when the mouse is hovered In that row, the background will turn to light gray.
sortClassdata-sort-classStringundefinedDeclare the class name of table td, which represents the class name of the elements in this column that will be sorted
heightdata-heightNumberundefinedHeight of the table
undefinedTextdata-undefined-textString-When no content is written, the default display is '-'
stripeddata-stripedBooleanfalseThe default is false. When set to true, the background of each row of the table will display gray and white
sortNamedata- sort-nameStringundefined Define which column's values ​​will be sorted. Write the custom name of the data-field. If it is not defined, it will not be sorted by default. Same as below. Used in combination with sortOrder. If not written, the column will be incremented by default (asc)
sortOrderdata-sort-orderStringasc Used in conjunction with the above, the default is increasing (asc), and can also be set to decrementing (desc)
sortStabledata-sort -stableBooleanfalse (Don’t read it wrong, it is sortStable, sortable is below) The default is false, if set to true, it is the same as the sort part, the difference is : During the sorting process, if there are equal elements, the original order will not change. There is another sentence in the original text: (If you set this attribute to true) We will add the '_position' attribute to this row
iconsPrefixdata-icons-prefixStringglyphiconDefine the font library ('Glyphicon' or 'fa' for FontAwesome). When using "fa", you need to reference FontAwesome and cooperate with the icons attribute to achieve the effect. Glyphicon is integrated into Bootstrap and can be used for free
iconSizedata-icon-sizeStringundefinedDefined icon size:
- undefined =>Default indicates the default button size (btn)
- xs =>Size of ultra-small button (btn-xs)
- sm =>Small button size (btn-sm)
- lg =>Large button size (btn-lg)
buttonsClassdata-buttons-classStringdefaultThe class of the button, the default is default.
- The options are: primary, danger, warning, etc.
- After writing, it will be automatically converted into btn-primary (blue), btn-danger (red), btn-warning (yellow) and other formats, so the front Do not add "btn-", the default is btn-default (white)
- Refer to the novice tutorial: Bootstrap button
iconsdata-iconsObject{ 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'
}
Define icons used in toolbars, paging, and detail views
- There is no way to explain, please refer to the icon of the novice tutorial: Bootstrap font icon
- Please refer to:
Check the Usage of Bootstrap-table
- That is, the data obtained from the server is obtained through the "." operator, such as "data.date/data.anything", followed by the field name sent by the server
- Original text: Get the key in each row of data json
- For example: {"name":"zz","age":20}, name and age are the keys, if this is requested from the server json, that may be different from the fields defined in each column, but they are all unique
methoddata-methodStringget向服务器请求远程数据的方式,默认为'get',可选'post'
urldata-urlStringundefined向服务器请求的url。
- 例如:server + "get_app_player"和server + 'get_channel_list',两者都是向server(server是自己定义的,例如"http://kanshakan.nichousha.com/")请求数据,只是接口不同,一个是请求该游戏玩家信息,一个是请求渠道信息
下面看看原文:
- 向远程站点请求数据的URL
- 请记住,如果服务端分页选项使用了自定义的,那么请求的服务器响应格式是不同的,参考下面两个数据格式:
Without server-side pagination(没有启用服务端分页 - data1.json)
With server-side pagination(启用服务端分页 - data2.json)
cachedata-cacheBooleantrue默认缓存ajax请求,设为false则禁用缓存
contentTypedata-content-typeStringapplication/json请求数据的contentType(内容类型),用于定义文件的类型,决定接收方以什么形式读取这个文件。
- 默认application/json,用来告诉接收端从服务器发来的消息是序列化后的json字符串
dataTypedata-data-typeStringjson期望从服务器获取的数据的类型,默认为json格式字符串
ajaxOptionsdata-ajax-optionsObject{}向服务器请求ajax时的附加项,默认无附加
- 参考 jQuery.ajax()
queryParamsdata-query-paramsFunction
function(params){
return params;}
Copy after login
当请求数据时,你可以通过修改queryParams向服务器发送其余的参数。
- queryParamsType="limit",它的参数包括:limit,offset,search,sort,order Else
- params包括:pageSize,pageNumber,searchText,sortName,sortOrder
- 当return false,请求则终止
queryParamsTypedata-query-params-typeStringlimit默认"limit",设置该属性用来发送符合RESTful格式的参数
responseHandlerdata-response-handlerFunction
function(res){
return res;}
Copy after login
在加载服务器发送来的数据之前,处理数据的格式,参数res表示the response data(获取的数据)
paginationdata-paginationBooleanfalse默认为false,表格的底部工具栏不会显示分页条(pagination toolbar),可以设为true来显示
paginationLoopdata-pagination-loopBooleantrue默认true,分页条无限循环
onlyInfoPaginationdata-only-info-paginationBooleanfalse前提:pagination设为true,启用了分页功能。
- 默认false,设为true显示总记录数
sidePaginationdata-side-paginationStringclient设置在哪进行分页,默认"client",可选"server",如果设置 "server",则必须设置url或者重写ajax方法
- 请记住,如果服务端分页选项使用了自定义的,那么请求的服务器响应格式是不同的,参考下面两个数据格式:
Without server-side pagination(没有启用服务端分页)
With server-side pagination(启用服务端分页)
pageNumberdata-page-numberNumber1前提:pagination设为true,启用了分页功能。
- 默认第1页,用于设置初始的页数
pageSizedata-page-sizeNumber10前提:pagination设为true,启用了分页功能。
- By default, 10 records are displayed per page, which is used to set the initial number of records displayed on each page
pageListdata-page-listArray [10, 25, 50, 100]Prerequisite: pagination is set to true and the paging function is enabled.
- The default is [10, 25, 50, 100], that is, you can select "Display 10/25/50/100 records per page" to set the number of records displayed per page
selectItemNamedata-select-item-nameStringbtSelectItemradio (radio button) or checkbox (complex Field name of the selection box
smartDisplaydata-smart-displayBooleantrue The default is true, which willtactfully(<_<)display pagination or card view according to the situation
escapedata-escapeBooleanfalse Skip the string inserted into HTML and replace the special characters (no commas in the following symbols): &, <, >,",`,'
- The content initially displayed in the search box, the default empty string
-Set the timeout for search files (original text: Set timeout for search fire, I don’t know if I wrote it wrong or my knowledge is too narrow. What does "search fire" mean? Is the official API wrong?Give me a hard time)
trimOnSearchdata-trim-on-searchBooleantrue Default true, automatically ignore spaces
showHeaderdata-show-headerBooleantrue The default is true to display the header, set to false to hide
showFooterdata-show-footerBooleanfalseThe default is false to hide the table footer, set to true to display
showColumnsdata-show-columnsBoolean falseThe default is false to hide a column drop-down menu, set to true to display
showRefreshdata-show-refresh BooleanfalseThe default is false to hide the refresh button, set to true to display
showToggle data-show-toggleBooleanfalseThe default is false to hide the view switching button, set to true to display
showPaginationSwitch data-show-pagination-switchBooleanfalseThe default is false to hide the selection of the number of data items per page, set to true to display
minimumCountColumnsdata-minimum-count-columnsNumber1The drop-down menu for each column is minimum The number
idFielddata-id-fieldStringundefined indicates which field is Identification field
uniqueIddata-unique-idStringundefined indicates that each row is unique The identifier of
cardViewdata-card-viewBooleanfalsedefault is false, Set to true to display card view
detailViewdata-card-viewBooleanfalseDefault is false, set to true to display detail view
detailFormatterdata-detail-formatterFunctionfunction(index, row, element){
return '';}
Prerequisite: detailView is set to true and the display of detail view is enabled.
- Used to format the detail view
- Returns a string, which is directly added to the cell (a certain grid) of the detail view through the third parameter element, where element is the jQuery element of the target cell
searchAligndata-search-alignStringrightThe position of the search box, default right (rightmost), optional left
buttonsAligndata-buttons-alignStringrightThe position of the toolbar button, default right (rightmost) , optional left
toolbarAligndata-toolbar-alignStringleftCustomized The position of the toolbar, default right (rightmost), optional left
paginationVAligndata-pagination-v-alignStringbottomThe vertical position of the paging bar, the default is bottom (bottom), optional top, both (both top and bottom have paging bars)
paginationHAligndata-pagination-h-alignStringrightThe horizontal position of the paging bar, default right (rightmost), optional left
paginationDetailHAligndata-pagination-detail-h-alignStringleftif The explanation is too long. For example, paginationDetail is "display the 1st to 8th records, a total of 15 records and display 8 records per page". The default is left (the leftmost), and the optional right
paginationPreTextdata-pagination-pre-textString Still giving an example, if you have too much content, The rightmost corner of the bottom will display: "‹ 1 2 3 4 5 ›" to select the number of pages. The default is the leftmost symbol, the same as below
paginationNextTextdata- pagination-next-textStringRefer to the above item
clickToSelectdata-click -to-selectBooleanfalseThe default false is no response. If set to true, when you click somewhere in this row, the checkbox of this row will be automatically selected ( checkbox) or radiobox (radio button)
singleSelectdata-single-selectBoolean#falseDefault is false, set to true to allow the check box to select only one row
toolbardata-toolbarString | NodeundefinedjQuery selector, for example: #toolbar, .toolbar , or DOM node
checkboxHeaderdata-checkbox-headerBooleantrue If you have a declaration check box, the select all check box of the header row will be displayed by default. Set it to false to hide it (that is, the first row of the table will not be displayed, and everything from the second row onwards will be displayed)
maintainSelecteddata-maintain-selectedBooleanfalseSet to true to maintain the status of the selected row
sortabledata-sortableBooleantrueDefault true, set to false to disable all Row arrangement (that is, the sorting button will not be displayed in the header of each column. This needs to be declared in th data-sortable="true", written in js but only enabled or not)
slientSort data-silent-sortBooleantruePrerequisite: sidePagination is set to server (server)
- Default true, set to If false, the data will be sorted silently
rowStyledata-row-styleFunction{} Changing the format of a row requires two parameters:
- row: The data of this row
- index: The index of this row
Supports classes and css. The usage is as follows: function rowStyle(row, index){
return { classes: 'text-nowrap another-class',
css: {"color": "blue", "font-size": "50px"}
}; }
rowAttributesdata-row-attributesFunction{}Change the Attributes require two parameters:
- row: the data of this row
- index: the index of this row
Supports all custom attributes.
customSearchdata-custom-searchFunction$.noopCustom search function (Used to replace the built-in search function), one parameter is required:
- text: the content you want to search for
The usage is as follows:
function customSearch(text){
//You must use 'this.data' to filter the data (filter the data, I feel that this word does not need to be translated), do not use 'this.options.data' }
customSortdata-custom-sortFunction$.noopCustom sort function (used to replace the built-in sorting function), requires two parameters (you can refer to the previous one):
- sortName: the column that needs to be sorted
- sortOrder: sorting method
Usage: the same as above, Don’t worry, the comments are exactly the same
localedata-localeStringundefinedLocalization (verb).
Localized files must be preloaded to allow fallback (simply put, if the file to be used is not available, you can replace it with something else, such as a substitute on the pitch. If there is no substitute, if someone is injured, the game will not stop. (deprecated), if loaded, it will be in the following order:
- First try to load the specified "localization" file
- Then '_' (underscore) is written as '-' (dash), and the region The code is capitalized
- then the short locale code (e.g. 'fr' instead of 'fr-CA')
- and finally the remaining localization file is used (the default is used when there is no file to load )
If the remaining undefined or empty characters are used, the last used file will be used (when no localization file can be loaded, the built-in 'en_US' will be used)
footerStyledata-footer-styleFunction{}Changing the footer format requires two parameters:
- row: the data of this row
- index: the index of this row
Supports classes and css, the usage is as follows:
function rowStyle(value, row, index){
return { css: { "font-weight": "bold" } }; }


##Column options

Defined in the jQuery.fn.bootstrapTable.columnDefaults file


footerFormatterdata-footer-formatterFunctionundefinedThe object that requires this column.​ sorterdata-sorterFunctionundefinedCustom sorting function, to implement local sorting, requires two parameters: sortNamedata-sort-nameStringundefinedExcept for the header The default sort-name or the field name of the column, you can also use a customized sort-name## cellStyledata-cell-styleFunctionundefinedTo change the display style (style) in a certain cell, three functions are required: function cellStyle(value, row, index, field) { return { classes: 'text-nowrap another-class', css: {"color": "blue", "font-size": "50px"} }; }BooleantrueThe default is true, which means this column of data Can be queriedsearchFormatterdata-search-formatterBooleantrueDefault true, Can use formatted data queryescapedata-escapeBooleanfalse jump By inserting the string in HTML, replace the special characters (no commas in the following symbols): &, <, >, ", `, '

Events

定义事件的格式:

$(’#table’).bootstrapTable({
onEventName: function (arg1, arg2, …) {
// …
} });

$(’#table’).on(‘event-name.bs.table’, function (e, arg1, arg2, …) {
// …
});
Copy after login
NameAttributeTypeDefault valueFunction description
radiodata-radioBooleanfalseThe default false is not to display the radio (radio button), if set to true Display, the radio width is fixed
checkboxdata-checkboxBoolean#falseDefault false does not display the checkbox (checkbox), set to true to display, the width of each column of the checkbox has been fixed
fielddata-fieldStringundefined is the field name of each column, not the name displayed in the table header. You can assign a value to it through this field name, which is equivalent to the key and is unique in the table
titledata-titleStringundefinedThis is the name displayed in the header, it is not unique. If you like, you can set all headers to the same name
titleTooltipdata-title-tooltipStringundefinedWhen hovering over a control, a prompt appears
- Refer to Bootstrap Tooltip plugin
classclass/data-classStringundefinedNothing to say, just class
rowspanrowspan/data-rowspanNumberundefinedThe number of rows occupied by each cell
colspancolspan/data-colspanNumber undefinedThe number of columns occupied by each cell
aligndata-alignStringundefinedThe alignment of data in each cell includes: left (left), right (right), center (center)
haligndata-halignStringundefinedThe alignment of table header (table header) includes: left (left), right (right) , center (center)
faligndata-falignStringundefinedtable footer( Table foot, just translate it like this, willfully, in fact, you can translate it casually, just know it) The alignment methods are: left (left), right (right), center (center)
valigndata-valignStringundefinedThe alignment of each grid of data includes: top (top), middle (centered) ), bottom (bottom)
widthdata-widthNumber (unit: px or %)undefined The width of each column.
- If there is no custom width, the width will adapt according to the width of the content.
- If the table is left responsive or the set width is smaller than the width of the content, then the width will still be adaptive (min-width or max-width can be used in class or other attributes).
- You can also use "%" as the unit, in this case, the bootstapTable will be divided by percentages. If you want to use "pixels (pixel value)", you can just write numbers (as long as you don't add "%", the unit defaults to "px" , if you don’t mind it, or if you want it to be clearer, you can also add "px")
sortabledata-sortableBooleanfalseThe default is false and it will be displayed by default. If set to true, it will be sorted
orderdata-orderStringascThe default sorting method is "asc (ascending order)", which can also be set to "desc (descending order)".
- Use it in conjunction with the above, otherwise it won't be sorted. What else do you think about lifting and lowering.
visibledata-visibleBooleantrueThe default is true to display this column, set If false, the column will be hidden.
                         - It is still very useful, for example, hiding the custom index column, which will be messed up after sorting by a certain attribute, you can read the index of a certain row to assign the value
cardVisibledata-card-visibleBooleantrueThe default is true to display this column, and set it to false to hide it.
switchabledata-switchableBooleantrueThe default is true to display this column, set False disables the column item's tab.
clickToSelectdata-click-to-selectBooleantrueDefault true does not respond , set to false, when you click somewhere in this row, the checkbox (checkbox) or radiobox (radio button) of this row will not be automatically selected
formatter data-formatterFunctionundefinedAn object that requires this column.
The data conversion function of a certain grid requires three parameters:
-value: field (field name) -row: row data
-index: row (index) index
​ ​ The data conversion function of a certain grid requires one parameter: ​ ​
​ ​ -data: an array of all row data ​
The function needs to return (return) the format of the string to be displayed in a certain cell of the footer, and also include the content
eventsdata-events ObjectundefinedWhen a certain grid uses the formatter function, the event listener will respond and requires four parameters:
   —event: jQuery event (refer to Events).
-Value: Field name
-row: line data
- Index: The line of this line for example:
& lt; th .. data -events = "operateEvent" & gt; var operateEvents = {'click .like': function (e, value, row, index) {}};
                                                                                                                                                                                         
Field names
                                                                                                                                                                                                                                                                the default sort-name but the field name of the column to be used. abc, but the content in the html code is arranged: abc

                                                                                                                                                                                                                                                  # Supports classes and css, usage is as follows:


searchable

data-searchable
onUncheckuncheck.bs.tablerow, $elementTriggered when this row is unselected (uncheck), the required parameters are as follows: onCheckAllcheck-all.bs.tablerowsTriggered when all rows are selected, the required parameters are as follows:     uncheck-all.bs.tableTriggered when certain rows (multiple rows, rows) are selected (check), the required parameters are as follows:           rowsWhen unchecking some rows ( Triggered when multiple lines, rows), the required parameters are as follows: ## on #dataTriggered when all data is loadedonLoadErrorload-error.bs.tablestatus, res Triggered when an error occurs while loading some dataonColumnSwitchcolumn-switch.bs.tablefield, checked Triggered when a column changes the visible statusonColumnSearchcolumn-search.bs.tablefield, textTriggered when a column is queriedonPageChangepage-change.bs.tablenumber, sizeTriggered when the number of data items displayed on this page is changed or the page number is changedonSearchsearch.bs.table textTriggered when querying this tableonToggletoggle.bs.tablecardView Fired when the view of the table is changedonPreBodypre-body.bs.tabledataWhen Triggers before the content in is displayedonPostBodypost-body.bs.tabledataIt will be triggered when the content in is loaded or defined in the DOM you are usingonPostHeader post-header.bs.tablenoneTriggered when the content in is loaded or defined in the DOM you are usingonExpandRowexpand-row.bs.tableindex, row, $detailWhen viewing the detailed view (click to view detail icon)onCollapseRowcollapse-row.bs.tableindex, rowis triggered when detail is closed Triggered when view (click the icon to view details again) onRefreshOptionsrefresh-options.bs.tableoptions Triggered after refreshing items or before initializing the table (including destruction and re-initialization)##Fired when the view of the table is resetonRefresh                                                                                                 refresh.bs.tableparamsWhen you click the refresh button (refresh, not the browser, but the upper right corner of the table Triggered after the refresh button)

Methods

#Define the syntax of method response $('#table').bootstrapTable(' method', parameter);

事件名定义在jQuery中的事件名参数作用描述
onAllall.bs.tablename, args当所有触发器被触发时都执行此函数,就是所有的事件都会触发该事件,参数包括:
- name:事件名
- args:事件的数据
onClickRowclick-row.bs.tablerow, $element, field当单击此行的任意一处,就会触发该事件,所需参数如下(只是按原文译过来的,在bootstraptable的js中不需要这些参数,因为单击该行就会获得一个row,row中包括此行所有数据,只要通过此行某列的字段名即可取出):
- row:哪一行(从0开始)
- $element:该行(tr)
- field:当点击该行,你想获取此行哪一格的数据,field就是此列字段名
onDblClickRowdbl-click-row.bs.tablerow, $element, field和上面差不多,当双击(666)此行的任意一处,就会触发该事件,所需参数如下(只是按原文译过来的,在bootstraptable的js中不需要这些参数,因为双击该行就会获得一个row,row中包括此行所有数据,只要通过此行某列的字段名即可取出):
- row:哪一行(从0开始)
- $element:该行(tr)
- field:当点击该行,你想获取此行哪一格的数据,field就是此列字段名
onClickCellclick-cell.bs.tablefield, value, row, $element当单击某一格,就会触发该事件,所需参数如下:
- field:此格所在列的字段名
- value:此格的数据
- $element:此行的此列,就是此格(td)
onDblClickCelldbl-click-cell.bs.table field, value, row, $element当双击某一格,就会触发该事件,所需参数如下:
- field:此格所在列的字段名
- value:此格的数据
- $element:此行的此列,就是此格(td)
onSortsort.bs.tablename, order当对某列进行排序时触发该事件,所需参数如下:
- name:所排序的列的字段名
- order: The order
onCheckcheck.bs.tablerow, $elementwhen selected ( Triggered when checking) this row, the required parameters are as follows: - row: the field name of the selected row
- $element: the DOM element of this row
- row : The field name of the deselected row
       - $element: The DOM element of this row
                                                                                                                                                                                                                                                                       
#onUncheckAll
rowsTriggered when all rows are unselected, the required parameters are as follows:                                                                                                                                       . : An array of field names of the previously or previously selected rowsonCheckSome
                                                                                                                                                                                                      # ArrayonUncheckSomeuncheck-some.bs.table
-s: the field name of the line name selected by Previously before or last time
onResetViewreset-view.bs.table
##removeByUniqueId-Remove a certain row of data (set the id of a certain row)$table.bootstrapTable('removeByUniqueId', 1);The following 1 is the ID of the row you want to remove insertRowparamsAdd a new row, the required parameters are as follows:$table.bootstrapTable(' insertRow', {index: 1, row: row}); ##updateRow - index: the index of the row to be updated - Please check: updateByUniqueId - id: What do you want to update? The id of the row (unique), (as long as you are willing, change whichever one you want to change) - Please see: ##showRowparamsShow specific rows, The required parameters include at least one of the following: - uniqueId: the id of that row showRow/hideRowparams - id: the index of the row to be hidden ##mergeCellsoptionsMerge~ (merge multiple cells into one), the required parameters are as follows:mergeCellsupdateCellparamsUpdate a certain cell of data, the required parameters are as follows: - field: the field name of the column refreshparams Refresh server data: Secretly (<_<) refreshoptionsrefreshOptionstextresetSearchnone Show loading... - Please check: none Hide loading... - Please check: none Select all rows of the current page$table.bootstrapTable('checkAll');checkAll/uncheckAllnoneUnselect all rows on the current page$table.bootstrapTable('uncheckAll');checkAll/uncheckAllInverse selection, it’s not difficult to understandSelect a row, the index starts from 0- Please check: check/uncheck##showColumnfield Show specific columns$table.bootstrapTable('showColumn', 'name');hideColumnfieldHide specific columns$table.bootstrapTable('hideColumn', 'name');getHiddenColumns-Get all hidden columns$ table.bootstrapTable('getHiddenColumns');getVisibleColumns-Get all displayed columns$table.bootstrapTable ('getVisibleColumns');scrollTovalueScroll...to which position, the unit is 'px', if set to 'bottom ', Whoosh, congratulations, you have reached the end of the table$table.bootstrapTable('scrollTo', 0);getScrollPositionnoneGet the current scroll position, you know the unit is 'px'$table.bootstrapTable('getScrollPosition'); filterBynone can only be used on the client side (client-side, relative to server-side) to filter the data in the table ##selectPagepageJump to a specific page$table.bootstrapTable('selectPage', 1);prevPagenoneJump to the previous page$table.bootstrapTable('prevPage');nextPagenoneJump to the next page$table.bootstrapTable('nextPage');togglePaginationnoneIf you are short of words, please see the example paper $table.bootstrapTable('togglePagination');toggleViewnone Change View$table.bootstrapTable('toggleView'); expandRowindexUsable conditions: detail view is set to true, otherwise the view function cannot be used, and this is useless - Please check: collapseRowindexAvailable conditions: detail view setting In order to be true - Please see: expandAllRows is subtableUsable conditions: detail view is set to true$table.bootstrapTable('expandAllRows'); collapseAllRowsis subtableUsable conditions: detail view is set to true$table.bootstrapTable ('collapseAllRows');


本地化,切换为另一种语言(Localizations)

默认显示英文,如果想使用中文,首先引入:

<script src="bootstrap-table-zh-CN.js"></script>
Copy after login

然后是三种声明使用的方法(个人只使用第二、三种),如下:


第一种:

$.extend($.fn.bootstrapTable.defaults, $.fn.bootstrapTable.locales[&#39;zh-CN&#39;]);
Copy after login

第二种:

<table data-toggle="table" data-locale="zh-CN"></table>
Copy after login

第三种:

$(&#39;table&#39;).bootstrapTable({locale:&#39;zh-CN&#39;});
Copy after login


以下说明除了数字外均为中文默认显示,本来不用写的,只要引入就显示中文了

Method nameParametersDescriptionExample
getOptionsnoneReturn the object of each item$table.bootstrapTable('getOptions');
- Please check: getOptions
getSelectionsnoneReturns the selected rows. When no rows are selected, an empty array is returned (but it is not undefined or null, it is the length. An empty array of 0, so you can determine whether the length is greater than 0 to determine whether a row is selected) $table.bootstrapTable('getSelections');
- Please check: getSelections
getAllSelectionsnoneReturn all selected rows (in the original text: contain search or filter, which is actually the filtered data you selected ), when no row is selected, an empty array is returned $table.bootstrapTable('getAllSelections');
- Please see: getAllSelections
showAllColumnsnoneShow all columns$table.bootstrapTable('showAllColumns');
- Just show all columns, nothing Sayable
hideAllColumnsnoneHide all columns$table.bootstrapTable('hideAllColumns');
       - That is to hide all columns
getDatauseCurrentPageGet the data of the loaded table, if you set the use of the current page data (useCurrentPage), then return the data of the current page$table.bootstrapTable('getData');
- Please check: getData
getRowByUniqueIdidGet the data of a row you want (set the id of a row) $table.bootstrapTable('getRowByUniqueId', 1) ;The following 1 is the ID
of the row you want - Please check: getRowByUniqueId
loaddataLoad data into the table, the original data will be removed$table.bootstrapTable('load', data);
- Please see: load
appenddataAppend data after the last line $table.bootstrapTable('append', data);data can be an array
- Please check: append
prependdata It is also appended, just before the first line$table.bootstrapTable('prepend', data);data can be an array
- Please check: prepend
removeparamsRemove one or more rows of data you selected$table.bootstrapTable(' remove', {field: 'id', values: ids});
- id: the field of the row (rows, one or more rows) that needs to be removed
- values: the row to be removed Array of
- Please view: remove
removeAll-Remove all data in the table$table.bootstrapTable('removeAll');
- Please see: removeAll
- Please check:
removeByUniqueId
- index: Where do you want to insert (as long as you are willing, you can insert wherever you want, insert whoever you want)
- row: The data you want to insert
- Please see:
insertRow
paramsUpdate row data, the required parameters are as follows: - row: the new data you want to change

$table .bootstrapTable('updateRow', {index: 1, row: row});
updateRow

paramsUpdate a row of data, the required parameters are as follows: - row: the new data you want to change

$table.bootstrapTable('updateByUniqueId', {id: 3, row: row});
updateByUniqueId
- id: the index of the row to be displayed
$table.bootstrapTable('showRow ', {index:1});
- Please view:

##hideRow
Hide a specific row. The required parameters include at least one of the following: - uniqueId: the id of that row$table.bootstrapTable('hideRow', {index:1});
- Please check: showRow/hideRow
getRowsHiddenbooleanGet the hidden rows (there are many official words, but in fact, the previous sentence is the summary) $table.bootstrapTable( 'getRowsHidden');
- Index: The index of the grid to be merged (INDEX)
- Field: The field name of the list
- rowspan:
##$table.bootstrapTable('mergeCells', {index: 1, field: 'name', colspan: 2, rowspan: 3});
- Please view:

- index: The index of the row where the cell to be merged is located (index) - value: the new data to be replaced
You can also set {reinit:false} to disable re-initialization of the table

$table.bootstrapTable('updateCell',{index:index,field:'id',value:value});
- You can set {silent:true} to Refresh
- Set {url:newUrl,pageNumber:pageNumber,pageSize:pageSize} to change the requested address, page number, and number of items displayed on each page - You can set {query:{foo:'bar'}} to increase Specific parameters

$table.bootstrapTable('refresh');
- Please see:

##refreshOptions
Let’s see an example - Please view: resetSearch
Reset the search text (text) - Please see: ##showLoading
showLoading/hideLoadinghideLoading
showLoading/hideLoadingcheckAll
- Please check:
uncheckAll
- Please check:
##checkInvertnone
$ table.bootstrapTable('checkInvert');checkindex
$table.bootstrapTable('check', 1);
uncheckindexUnselect a row, the index is from 0 Start$table.bootstrapTable('uncheck', 1);
- Please check: check/uncheck
checkByparamsSelect a row through an array. The required parameters are as follows:
- field: the name of the field to be selected
- values: the values ​​(array) to be selected
No official, ah, there is an example:
- $("#table").bootstrapTable("checkBy", { field:"field_name", values:["value1","value2"," value3"]});
- Please check: checkBy/uncheckBy
uncheckByparamsPass array To select a row, the required parameters are as follows:
- field: the field name to be deselected
- values: the values ​​(array) to be deselected
$("#table") .bootstrapTable("uncheckBy", { field:"field_name", values:["value1","value2","value3"]});
- Please check: checkBy/uncheckBy
resetViewparamsChange the style of the table, such as changing the height of the table $table.bootstrapTable('resetView ');
- Please check: resetView
resetWidthnoneAutomatically change the header and footer (Translated into feet, arbitrary) width to adapt to the width of each column$table.bootstrapTable('resetWidth');
destroynoneDestroy Form A! T! T! Ah! C! K! $table.bootstrapTable('destroy');
- Please view: destroy
- Please check:
showColumn/hideCoulumn
- Please check:
showColumn/hideCoulumn
- Please check:
scrollTo
For example:
- You can set {age:10} to only display data with age 10
- Not only single, you can also fly in pairs, or even multiple people, set {age: 10, hairColor: ["blue", "red", "green"]}, so that you get a group of 10-year-olds with hair colors of Blue, red, green...data
$table.bootstrapTable('filterBy', { id: [1, 2, 3] });
- Please check: filterBy
- Please view:
selectPage/prevPage/nextPage
- Please check:
selectPage/prevPage/nextPage
      - Please check:
selectPage/prevPage/nextPage
- Please view:
togglePagination
- Please view:
toggleView
- Expand the detailed view of this column through the parameter index
expandRow-collapseRow
- Close the detailed view of this column through the parameter index
expandRow-collapseRow
There are changes in the new version (originally "expandAllRow"), the same as below
Thanks @zhq449681061
- Expand all columns Detailed view
- Refer to the above example, the above is the view of expanding (collapsing) a certain row, this is the view of all rows
- Close the detailed view of all columns
- Refer to the above
名称 参数 默认 说明
formatLoadingMessage - 'Loading, please wait…' “加载中,请等待……”
formatRecordsPerPage pageNumber '%s records per page' “每页显示 15  条记录”
formatShowingRows pageFrom, pageTo, totalRows 'Showing %s to %s of %s rows' “显示第 1 到第 15 条记录”
formatDetailPagination totalRows 'Showing %s rows' “总共 15 条记录”
formatSearch - 'Search' “搜索”(占位符)
formatNoMatches - 'No matching records found' “没有找到匹配的记录”
formatRefresh - 'Refresh' “刷新”(鼠标悬浮显示的文字,下同)
formatToggle - 'Toggle' “切换”
formatColumns - 'Columns' “列”

  有错请留言,看到后会及时更改,如果像那种翻译的行写成列或漏字等低级错误,看英文名称就知道有没有错了,主要就是为了让你们知道怎么用,会持续检查哪有误、漏译,如果认为有译得不妥的地方,也可以留言一起讨论,谢谢

The above is the detailed content of Bootstrap Table API Chinese version (translation document). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template