您的位置:首页 > Web前端 > BootStrap

bootstrap-table 分页

2017-09-29 12:33 302 查看
----------------------前台

<%--

查询按钮事件

--%>

function search()

{

$('#tableList').bootstrapTable("refresh");

}

<%--

初始化

--%>

$(function () {

//1.初始化Table

var tableInit = new TableInit();

tableInit.Init();

});

var TableInit = function () {

var oTableInit = new Object();

//初始化Table

oTableInit.Init = function () {

$('#tableList').bootstrapTable({

url: 'queryQuestion.action', //请求后台的URL(*)

queryParamsType: 'limit',

method: 'post', //请求方式(*)

sidePagination: "server", //分页方式:client客户端分页,server服务端分页(*)

pagination: true,

limit:10, //初始化加载第一页,默认第一页

offset: 0, //每页的记录行数(*)

pageList: [10, 25, 50, 100], //可供选择的每页的行数(*)

height: 500, //行高,如果没有设置height属性,表格自动根据记录条数觉得表格高度

columns: [

{

field: 'id',

title: '编号'

},

{

field: 'type',

title: '类型'

},

{

field: 'name',

title: '问题'

},

{

field: 'content',

width:500,

title: '内容',

formatter:function(value,row,index){

var e = '呵呵';

return e;

}

},

{

field: 'content',

title: '删除',

formatter:function(value,row,index){

var e = '<a href="#" mce_href="#" onclick="edit(\''+ row.id + '\')">编辑</a> ';

return e;

}

}

],

queryParams: function (params) {

return {

questionName:$("#questionName").val(),

limit: params.limit,

offset: params.offset

}

},

});

};

return oTableInit;

}

------------后台

@RequestMapping(value = "/queryQuestion" )

@ResponseBody

public Map<String,Object> login( @RequestBody JSONObject jsonObj) {

System.out.println(jsonObj.toString());

Integer limit = jsonObj.getInteger("limit");

Integer offset = jsonObj.getInteger("offset");

QuestionVO parameters = new QuestionVO();

parameters.setLimit(limit);

parameters.setOffset(offset);

parameters.setName(jsonObj.getString("questionName").trim());

Map<String,Object> map = new HashMap<String,Object>();

System.out.println(parameters.getLimit());

System.out.println(parameters.getOffset());

List<QuestionVO> resultList = qstDao.queryQuestionByPage(parameters);

int count = qstDao.queryQuestionCount(parameters);

map.put("rows", resultList);

map.put("total",count);

return map;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: