Detailed explanation of the use of bootstrap Table plug-in
This article mainly introduces the demo of using the bootstrap Table plug-in. The editor thinks it is quite good, so I will share it with you now and give it as a reference. Let’s follow the editor to take a look.
I recently studied bootstrap. It only provides visual effects and does not cover data lists and the like. I searched online and found a Table plug-in.
Named bootstrapTable.
Official address: http://bootstrap-table.wenzhixin.net.cn/examples/
github: https://github.com/wenzhixin/bootstrap -table
Because of my poor English, I studied for a long time and made a demo. I just looked at
HTML:
##
<table class="table" id="dataShow" > <thead> <tr> <th data-checkbox="true">选择</th> <th data-field="rkey">供应商名称</th> <th data-field="rkey">供应商编码</th> <th data-field="name">物料编码</th> <th data-field="sex">申请类型</th> <th data-field="birthdayString">试用申请编码</th> <th data-field="age">试用状态</th> <th data-field="age">厂别</th> <th data-field="age">审批状态</th> <th data-field="birthday">申请时间</th> <th data-field="age">试用结果</th> </tr> </thead> </table>JS:
##
var currPageIndex = 0; var currLimit = 10; $(function () { $("#dataShow").bootstrapTable({ url: "TradHandler.ashx?request=getTradList", sortName: "rkey",//排序列 striped: true,//條紋行 sidePagination: "server",//服务器分页 //showRefresh: true,//刷新功能 //search: true,//搜索功能 clickToSelect: true,//选择行即选择checkbox singleSelect: true,//仅允许单选 //searchOnEnterKey: true,//ENTER键搜索 pagination: true,//启用分页 escape: true,//过滤危险字符 queryParams: getParams,//携带参数 pageCount: 10,//每页行数 pageIndex: 0,//其实页 method: "get",//请求格式 //toolbar: "#toolBar", onPageChange: function (number, size) { currPageIndex = number; currLimit = size }, onLoadSuccess: function () { $("#searchBtn").button('reset'); } }); //搜索 $("#searchBtn").click(function () { $(this).button('loading'); var nullparamss = {}; $("#dataShow").bootstrapTable("refresh", nullparamss); }); //enter键搜索 $("#searchKey").keydown(function (event) { if (event.keyCode == 13) { $("#searchBtn").click(); } }); //阻止enter键提交表单 $("#mainForm").submit(function () { return false; }); }); //默认加载时携带参数 function getParams(params) { var searchKey = $("#searchKey").val(); return { bysex: 1, limit: params.limit, offset: params.offset, search: searchKey }; }
TradHandler.ashx:
/// <summary> /// 获取批量数据示例 /// </summary> /// <param name="context"></param> private void getTradList(HttpContext context) { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); #region 模拟数据获取 List<SimpleModel> list = new List<SimpleModel>(); for (int i = 0; i < 1000; i++) { list.Add(new SimpleModel() { age = 18, name = "小李" + i, rkey = i + 1, sex = "男" }); } //请求中携带的条件 string bysex = context.Request.Params["bysex"]; string searchKey = context.Request.Params["search"]; //請求中攜帶的頁數和下標 int dataIndex = Convert.ToInt32(context.Request.Params["offset"]); int pageCount = Convert.ToInt32(context.Request.Params["limit"]); //查询满足条件的数据 List<SimpleModel> getList; if (bysex != null && searchKey != null) { getList = (from p in list where p.sex == (bysex == "0" ? "女" : "男") && p.name.Contains(searchKey.Trim()) select p).ToList(); } else { getList = list; } #endregion //将结果增加一列序号列 Dictionary<int, SimpleModel> testModel = new Dictionary<int, SimpleModel>(); for (int i=0;i< getList.Count;i++) { testModel.Add(i + 1, getList[i]); } //给分页实体赋值 PageModels<SimpleModel> model = new PageModels<SimpleModel>(); model.total = getList.Count; if (getList.Count % pageCount == 0) model.page = getList.Count / pageCount; else model.page = (getList.Count / pageCount) + 1; //獲取對應頁的數據 model.rows = testModel.Where(t => t.Key > dataIndex && t.Key <= dataIndex + pageCount).Select(t => t.Value).ToList(); //将查询结果返回 context.Response.Write(jss.Serialize(model)); }
There are classmates Ask about the pagemodel entity class. I will also share here the generic entity class, because the plug-in requires these attributes to automatically bind normally
[Serializable] public class TablePageModel<T> { /// <summary> /// 總行數 /// </summary> public long total { get; set; } /// <summary> /// 总页数 /// </summary> public int page { get; set; } private List<T> _rows; /// <summary> /// 數據源 /// </summary> public List<T> rows { get { if (_rows == null) _rows = new List<T>(); return _rows; } set { _rows = value; } } }
The display data results are as follows:
The above is the detailed content of Detailed explanation of the use of bootstrap Table plug-in. For more information, please follow other related articles on the PHP Chinese website!

JavaScript's application in the real world includes front-end and back-end development. 1) Display front-end applications by building a TODO list application, involving DOM operations and event processing. 2) Build RESTfulAPI through Node.js and Express to demonstrate back-end applications.

The main uses of JavaScript in web development include client interaction, form verification and asynchronous communication. 1) Dynamic content update and user interaction through DOM operations; 2) Client verification is carried out before the user submits data to improve the user experience; 3) Refreshless communication with the server is achieved through AJAX technology.

Understanding how JavaScript engine works internally is important to developers because it helps write more efficient code and understand performance bottlenecks and optimization strategies. 1) The engine's workflow includes three stages: parsing, compiling and execution; 2) During the execution process, the engine will perform dynamic optimization, such as inline cache and hidden classes; 3) Best practices include avoiding global variables, optimizing loops, using const and lets, and avoiding excessive use of closures.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Python and JavaScript have their own advantages and disadvantages in terms of community, libraries and resources. 1) The Python community is friendly and suitable for beginners, but the front-end development resources are not as rich as JavaScript. 2) Python is powerful in data science and machine learning libraries, while JavaScript is better in front-end development libraries and frameworks. 3) Both have rich learning resources, but Python is suitable for starting with official documents, while JavaScript is better with MDNWebDocs. The choice should be based on project needs and personal interests.

The shift from C/C to JavaScript requires adapting to dynamic typing, garbage collection and asynchronous programming. 1) C/C is a statically typed language that requires manual memory management, while JavaScript is dynamically typed and garbage collection is automatically processed. 2) C/C needs to be compiled into machine code, while JavaScript is an interpreted language. 3) JavaScript introduces concepts such as closures, prototype chains and Promise, which enhances flexibility and asynchronous programming capabilities.

Different JavaScript engines have different effects when parsing and executing JavaScript code, because the implementation principles and optimization strategies of each engine differ. 1. Lexical analysis: convert source code into lexical unit. 2. Grammar analysis: Generate an abstract syntax tree. 3. Optimization and compilation: Generate machine code through the JIT compiler. 4. Execute: Run the machine code. V8 engine optimizes through instant compilation and hidden class, SpiderMonkey uses a type inference system, resulting in different performance performance on the same code.

JavaScript's applications in the real world include server-side programming, mobile application development and Internet of Things control: 1. Server-side programming is realized through Node.js, suitable for high concurrent request processing. 2. Mobile application development is carried out through ReactNative and supports cross-platform deployment. 3. Used for IoT device control through Johnny-Five library, suitable for hardware interaction.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools