【英文】BootstrapTable学习笔记
Preface
Implementing automatically paginated tables with BootstrapTable
Preparation
- Bootstrap related dependencies
- BootstrapTable related dependencies
- jQuery related dependencies
- Vue related dependencies (optional)
Importing Dependencies
1 | <link rel="stylesheet" href="dist/css/bootstrap.css"> |
Collaboration with Vue
- If using Vue, the following dependencies need to be imported
1 | <script src="dist/js/vue.js"></script> |
Generating Table in HTML
1 | <div id="table"> |
Configuring the Table in JS
1 | document.getElementById("table").bootstrapTable({ |
Configuring the Table in Vue.js
- This example is implemented through collaboration with Vue
Front-end Pagination
- Front-end pagination requires using
data{columns:[],data:[]}
to provide data for front-end processing, suitable for tables with no backend or small data volume columns
is used to define table headers,title
is used to define the header title,field
is used to define the field namedata
is used to define the data, which is composed of an array of objects, where the object’s key is thefield
field name and the value is the actual dataoptions
is used to define the table configuration, both front-end and back-end pagination require table configuration inoptions
1 | new Vue({ |
Back-end Pagination
- Back-end pagination requires obtaining table data by requesting the backend API
- BootstrapTable will pass the following parameters by default
offset
: The index of the first data in the current page in the data table, corresponding to the first parameter of theLIMIT
statement in SQLlimit
: The number of data in the current page, corresponding to the second parameter of theLIMIT
statement in SQL- More parameters (
search
,sort
,order
) can be found in the official documentation
- BootstrapTable expects the following format of JS object
{total: 1, rows: []}
total
: The number of all data, BootstrapTable uses it to determine the number of pages
- BootstrapTable will pass the following parameters by default