layui中的table的分页条件搜索
前端代码:
table.render({
elem: 'table的id'
,url: '搜索路径'
,where:{busName:''} //后台搜索条件
,cols: [[
、、、、
]]
,id: 'testReload' //和重载时填写的id相同
,page: true
,height: 310
});
//执行重载
table.reload('testReload', { //需要和上面的id相同
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
busName: demoReload.val()
}
}, 'businfo');
后台接受方法:
/**
*
* @param pageNum 页码数
* @param pageSize 显示的数量
* @param busName 搜索的条件
* @return
*/
public String selectBus(@RequestParam("page")int pageNum, @RequestParam("limit")int pageSize ,
@RequestParam("busName") String busName){
PageHelper.startPage(pageNum, pageSize);
//条件搜索
List<BusInfo> busInfoList = busInfoService.select(busName);
int count = busInfoList.size();
JSONObject jsonObject = new JSONObject();
jsonObject.put("code", 0);
jsonObject.put("msg", "");
jsonObject.put("count", count);
jsonObject.put("data", busInfoList);
return jsonObject.toJSONString();
}