datatables search
查询参数为: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>