For a table with complete functions and good user experience, the query function is indispensable, because the amount of data in the table may sometimes be quite large. At this time, if you need to find a specific data , that will be a very huge workload. Below we will introduce to you how to use the bootstrap table plug-in to implement the query function.
Recommended tutorial: Bootstrap video tutorial
Implementation query ideas:
1. Define a Toolbar on the left side of the page that contains buttons for create, save and create
2. Define a QueryForm on the right side of the page that includes query conditions and query clear buttons
3. Define a Table
The implementation effect is as follows:
The code is as follows
<div class="container-fluid"> <div> <div id="toolbar-btn" class="btn-group pull-left" style="padding-bottom:10px;"> <button id="btn_add" οnclick="createFunction()" type="button" class="btn btn-primary btn-space"> <span class="fa fa-plus-square" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.new"/> </button> <button id="btn_save" οnclick="saveFunction()" type="button" class="btn btn-success btn-space"> <span class="fa fa-save" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.save"/> </button> <button id="btn_delete" οnclick="deleteFunction()" type="button" class="btn btn-danger btn-space"> <span class="fa fa-trash-o" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.delete"/> </button> </div> <div class="pull-right" id="query-form" style="padding-bottom:10px;"> <input name="lookupType" placeholder='<@spring.message "fnd.lookup_type"/>' type="text" style="float:left;width:150px;margin-right:5px;" v-model="lookupType" class="form-control"> <div style="float:left;margin-right:5px;"> <input name="description" placeholder='<@spring.message "fnd.description"/>' type="text" style="float:left;width:150px;margin-right:5px;" v-model="description" class="form-control"> </div> <div class="btn-group"> <button id="btn_search" οnclick="customSearch()" type="button" class="btn btn-primary btn-space"> <span class="fa fa-search" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.query"/> </button> <button id="btn_reset" οnclick="resetSearch()" type="button" class="btn btn-default btn-space"> <span class="fa fa-eraser" aria-hidden="true" class="btn-icon-space"></span> <@spring.message "fnd.reset"/> </button> </div> </div> </div> <table id="table" class="table table-condensed table-striped"></table> </div>
Query function implementation
Implementation idea: get all the objects in the query block and dynamically store them in the parameters returned by the query
Note:
When the query has no value, it cannot Put it into the query parameters, otherwise the data will be queried as empty, resulting in the inability to query the data
function queryParams(params) { var param = {}; $('#query-form').find('[name]').each(function () { var value = $(this).val(); if (value != '') { param[$(this).attr('name')] = value; } }); param['pageSize'] = params.limit; //页面大小 param['pageNumber'] = params.offset; //页码 return param; } function customSearch(text) { $table.bootstrapTable('refresh');//刷新Table,Bootstrap Table 会自动执行重新查询 }
Reset function implementation
Implementation idea: loop Get the query-form control and set its value to blank
function resetSearch() { $('#query-form').find('[name]').each(function () { $(this).val(''); }); }
The above is the detailed content of Bootstrap Table query implementation. For more information, please follow other related articles on the PHP Chinese website!

BootstrapisafreeCSSframeworkthatsimplifieswebdevelopmentbyprovidingpre-styledcomponentsandJavaScriptplugins.It'sidealforcreatingresponsive,mobile-firstwebsites,offeringaflexiblegridsystemforlayoutsandasupportivecommunityforlearningandcustomization.

Bootstrapisafree,open-sourceCSSframeworkthathelpscreateresponsive,mobile-firstwebsites.1)Itoffersagridsystemforlayoutflexibility,2)includespre-styledcomponentsforquickdesign,and3)ishighlycustomizabletoavoidgenericlooks,butrequiresunderstandingCSStoop

Bootstrap is suitable for quick construction and small projects, while React is suitable for complex and interactive applications. 1) Bootstrap provides predefined CSS and JavaScript components to simplify responsive interface development. 2) React improves performance and interactivity through component development and virtual DOM.

The main purpose of Bootstrap is to help developers quickly build responsive, mobile-first websites. Its core functions include: 1. Responsive design, which realizes layout adjustments of different devices through a grid system; 2. Predefined components, such as navigation bars and modal boxes, ensure aesthetics and cross-browser compatibility; 3. Support customization and extensions, and use Sass variables and mixins to adjust styles.

Bootstrap is better than TailwindCSS, Foundation, and Bulma because it is easy to use and quickly develop responsive websites. 1.Bootstrap provides a rich library of predefined styles and components. 2. Its CSS and JavaScript libraries support responsive design and interactive functions. 3. Suitable for rapid development, but custom styles may be more complicated.

Integrating Bootstrap in React projects can be done in two ways: 1) introduced using CDN, suitable for small projects or rapid prototyping; 2) installation using npm package manager, suitable for scenarios that require deep customization. With these methods, you can quickly build beautiful and responsive user interfaces in React.

Advantages of integrating Bootstrap into React projects include: 1) rapid development, 2) consistency and maintainability, and 3) responsive design. By directly introducing CSS files or using the React-Bootstrap library, you can use Bootstrap's components and styles efficiently in your React project.

Bootstrap is a framework developed by Twitter to help quickly build responsive, mobile-first websites and applications. 1. Ease of use and rich component libraries make development faster. 2. The huge community provides support and solutions. 3. Introduce and use class names to control styles through CDN, such as creating responsive grids. 4. Customizable styles and extension components. 5. Advantages include rapid development and responsive design, while disadvantages are style consistency and learning curve.


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

Dreamweaver CS6
Visual web development tools

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

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

Zend Studio 13.0.1
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool