当前位置: 代码迷 >> 综合 >> datatables 查询功能代码备份
  详细解决方案

datatables 查询功能代码备份

热度:91   发布时间:2024-01-06 16:11:02.0

查询参数为:search[value]

@RequestMapping("/page")public Page<Logs> page(Integer start,Integer length,HttpServletRequest request) {String search=request.getParameter("search[value]");if (StringUtils.isNotEmpty(search)) {queryConditions.add(new QueryCondition("name", QueryCondition.LK, search));}else{queryConditions = new ArrayList<QueryCondition>();}Page<Logs> data = logsService.findPage(queryConditions, orderBy,new PageRequest(start, length));System.out.println(JSON.toJSONString(data));return data;}

DtRowSelected

var DtRowSelected=function(table){
    $('#dynamicData tbody').on( 'click', 'tr', function () {
    if ( $(this).hasClass('table-selected') ) {$(this).removeClass('table-selected');}else {table.$('tr.table-selected').removeClass('table-selected');$(this).addClass('table-selected');}} );}

js 备份:

<script type="text/javascript" th:inline="javascript">var cn_url =/*[[@{/plugs/datatables/zh_CN.json}]]*/;var page_url =/*[[@{/logs/page}]]*/;$(document).ready(function() {$(".logs").addClass("active");$(".system").addClass("active");var table=$('#dynamicData').DataTable({responsive: true,"processing": true,"oLanguage": {"sUrl": cn_url},"columnDefs": [{"targets": [ 0 ],"visible": false,"searchable": false}],"serverSide": true,"ajax": page_url,"columns": [{ "data": "id" },{ "data": "account" },{ "data": "name" },{ "data": "createtime" },{ "data": "content" },{ "data": "type" }]});DtRowSelected(table);});
</script>
  相关解决方案