Home > Web Front-end > JS Tutorial > body text

A lightweight Bootstrap Table plug-in worth sharing

高洛峰
Release: 2017-01-04 11:06:32
Original
3036 people have browsed it

Bootstrap Table is a lightweight table plug-in based on Bootstrap. With simple configuration, it can have powerful functions such as supporting fixed headers, single/multiple selection, sorting, paging, search and custom headers, etc., to better improve Development efficiency and reduced development time.

值得分享的轻量级Bootstrap Table表格插件

1. Plug-in description: Bootstrap Table displays data table format, providing rich support, radio buttons, check boxes, sorting, paging, etc.

2. Features:

Developed based on Bootstrap 3 (also supports Bootstrap 2)

Responsive interface

Fixed header

Completely available Configuration

Support data attribute

Show/hide columns

Show/hide header

Use AJAX to obtain JSON data

Click on the table Headers can be sorted simply

Support custom column display

Support single/check selection

Powerful paging function

Support business card layout

Support multiple languages

3. How to use:

1). Introduce the Bootstrap library (if your project has not yet used it) and bootstrap-table in the head tag of the html page. css.

<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="bootstrap-table.css">
Copy after login

2), introduce jQuery library and Bootstrap library (if your project has not used it yet) in the head tag or before the body tag is closed (more recommended) and bootstrap-table.js.

<script src="jquery.min.js"></script>
<script src="bootstrap.min.js"></script>
 <script src="bootstrap-table.js"></script>
Copy after login

3), specify the data source, there are two ways
Method 1: Through the data attribute label
In an ordinary table Setting data-toggle="table" enables Bootstrap Table without writing JavaScript.

<table data-toggle="table" data-url="data.json">
   <thead>
    ...
   </thead>
  </table>
Copy after login

Method 2: Set the data source through JavaScript
Enable the Table with the id attribute through JavaScript.

$(&#39;#table&#39;).bootstrapTable({
   url: &#39;data.json&#39;
  });:
Copy after login

4. Bug description:

值得分享的轻量级Bootstrap Table表格插件

When setting the field formatter using the label attribute method, it was found that there is no Effect

For example: gender
1), reason:
bootstrap-table.js Line 399, the code only determines the case where formatter typeof is function
2), solution:
Modify the code block on line 399:
Before modification

if (typeof that.header.formatters[j] === &#39;function&#39;) {
 value = that.header.formatters[j](value, item);
}
Copy after login

After modification:

if (typeof that.header.formatters[j] === &#39;function&#39;) {
     value = that.header.formatters[j](value, item);
    }else if(typeof that.header.formatters[j] === &#39;string&#39;) {
     if(typeof window[that.header.formatters[j]] === &#39;function&#39;) {
     value = window[that.header.formatters[j]](value, item);
     }
    }
Copy after login

The above is the method of using Bootstrap Table shared with everyone. I hope everyone can master the method of using Bootstrap Table. Helps.

For more articles related to the lightweight Bootstrap Table plug-in worth sharing, please pay attention to 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!