Home  >  Article  >  Web Front-end  >  Solve the problems encountered during the implementation of JS component bootstrap table paging

Solve the problems encountered during the implementation of JS component bootstrap table paging

高洛峰
高洛峰Original
2017-01-04 11:55:311584browse

This article shares the bootstrap-table paging problem for your reference. The specific content is as follows

Question 1: The server cannot get the form value. There is no problem with the querystring, but the request.form cannot be obtained. Value

Solution: This is an ajax problem. The original code uses native ajax. 1 can be solved by reading stream files. 2 If you want to use the request.form method, set contentType: "application/x-www-form-urlencoded",

such as

$('#tableList').bootstrapTable({
method: 'post',
url: "",
height: $(window).height() - 200,
striped: true,
dataType: "json",
pagination: true,
"queryParamsType": "limit",
singleSelect: false,
contentType: "application/x-www-form-urlencoded",

Question 2. Set the parameters passed to the server

Method:

function queryParams(params) {
 
return {
pageSize: params.limit,
 
pageNumber: params.pageNumber,
 
UserName: 4
 
};
 
}
 
 $('#tableList').bootstrapTable({
method: 'post',
url: "",
height: $(window).height() - 200,
striped: true,
dataType: "json",
pagination: true, 
 
queryParams: queryParams,

Problem 3. The pageSize information cannot be obtained in the background

Solution:

1Set in queryParams

2 In bootstrap- The table.minjs file modifies the source file to

"limit"===this.options.queryParamsType&&(e={limit:e.pageSize,pageNumber:e.pageNumber,

Modify bootstrap- table.js can also be

if (this.options.queryParamsType === 'limit') {
params = {
search: params.searchText,
sort: params.sortName,
order: params.sortOrder
};
if (this.options.pagination) {
params.limit = this.options.pageSize;
 
params.pageNumber=this.options.pageNumber,
params.offset = this.options.pageSize * (this.options.pageNumber - 1);
}
}

configured to add "queryParamsType": "limit",

complete

Question 4. Re-search after paging

Premise: Customized search with paging function, such as the function of searching product names.

Phenomenon: When searching for inflatable dolls, 100 records are returned and turned to the fifth page. At this time, when searching for massage sticks, There are 200 pieces of data, and the result should be the records on the first page, but the results on the fifth page are actually displayed. That is, after re-searching, the pagenumber has not changed.

Solution: Just reset the option.

function search(){
 
 $('#tableList').bootstrapTable({pageNumber:1,pageSize:10});
 
}

The above is the entire content of this article. I hope it will be helpful to everyone's study.

For more related articles on solving the problems encountered in the implementation of JS component bootstrap table paging, please pay attention to the PHP Chinese website. !


##

Statement:
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 [email protected]