English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

iOSの基本的なアニメーション、キーフレームアニメーション、エイリアシス関数を使用して物理アニメーション効果を実現する+SpringMVCに基づく+Bootstrap

前書き

iOSの基本的なアニメーション、キーフレームアニメーション、エイリアシス関数を使用して物理アニメーション効果を実現する+SpringMVCに基づく+DataTablesでデータテーブルのサーバーサイドページング、あいまい検索(DataTable Searchではありません)、ページの非同期リフレッシュを実現します。

説明:sp:messageタグはSpringMVCの国際化を使用しています

効果

DataTableテーブル

キーワード検索

カスタムキーワード検索、DataTable Searchではありません

コード

HTMLコード

検索条件コード

<!-- 検索、追加、一括削除、エクスポート、リフレッシュ -->
<div class="row-fluid">
<div class="pull-right">
<div class="btn-group">
<button type="button" class="btn btn-primary btn-sm" id="btn-add">
<i class="fa fa-plus"></i> <sp:message code="sys.add"/>
</button>
<button type="button" class="btn btn-primary btn-sm" id="btn-delAll">
<i class="fa fa-remove"></i> <sp:message code="sys.delAll"/>
</button>
<button type="button" class="btn btn-primary btn-sm" id="btn-export">
<i class="fa fa-sign-in"></i> <sp:message code="sys.export"/>
</button>
<button type="button" class="btn btn-primary btn-sm" id="btn-re">
<i class="fa fa-refresh"></i> <sp:message code="sys.refresh"/>
</button>
</div>
</div>
<div class="row">
<form id="queryForm" action="<%=path%>/goodsType/list" method="post">
<div class="col"}-xs-2">
<input type="text" id="keyword" name="keyword" class="form-control input-sm"
placeholder="<sp:message code="sys.keyword"/">"
</div>
<button type="button" class="btn btn-primary btn-sm" id="btn-query">
<i class="fa fa-search"></i> <sp:message code="sys.query"/>
</button>
</form>
</div>
</div>

データテーブルのコード

<table id="dataTable" class="table table-striped table-bordered table-hover table-condensed" align="center">
<thead>
<tr class="info">
<td><input type="checkbox" id="checkAll"></td>
<th><sp:message code="sys.no"/></th>
<th><sp:message code="goods.type.name.cn"/></th>
<th><sp:message code="goods.type.name.en"/></th>
<th><sp:message code="sys.create.time"/></th>
<th><sp:message code="sys.update.time"/></th>
<th><sp:message code="sys.oper"/></th>
</tr>
</thead>
</table>

JSコード

DataTablesの初期化、サーバー側データのリクエスト、クエリ条件のエンキャスメント

<!-- ページスクリプト -->
<script>
$(function () {
//追加、修正のアシンクリン提出先URL
var url = "";
var tables = $("#dataTable").dataTable({
serverSide: true,//ページネーション、データの取得などはすべてサーバー側に行う
processing: true,//データをロードする際に「ロード中」を表示するかどうか
pageLength: 10, //初回ロードのデータ行数
ordering: false, //ソート操作はサーバーサイドで行うため、無効にできます
pagingType: "full_numbers",
autoWidth: false,
stateSave: true,//ページング状態を維持し、comTable.fnDraw(false);と組み合わせて使用します
searching: false,//datatablesの検索を無効にする
ajax: { 

url: "<%=path%>/goodsType/getData",
dataSrc: "data",
data: function (d) {
var param = {};
param.draw = d.draw;
param.start = d.start;
param.length = d.length;
var formData = $("#queryForm").serializeArray();//form内のデータを配列にシリアライズする
formData.forEach(function (e) {
param[e.name] = e.value;
});
return param;//自定義で渡す必要のあるパラメータ。
},
},
columns: [//対応するthead内のシリアル
{"data": null,"width":"10px"},
{"data": null},
{"data": 'typeNameCn' },
{"data": 'typeNameEn' },
{"data": 'createTime', 
"render":function(data,type,full,callback) {
return data.substr(0,19) 
}
},
{"data": 'updateTime', defaultContent: "", 
"render":function(data,type,full,callback) {
if(data != null && data != ""){
return data.substr(0,19) 
}
return data;
}
}
},
{"data": null,"width":"60px"}
],
//操作按钮
columnDefs: [
{
targets: 0,
defaultContent: "<input type='checkbox' name='checkList'>"
},
{
targets: -1,
defaultContent: "<div class='btn-group'>"+
""+
""+
"
" } ], language: { lengthMenu: "", processing: "", paginate: { previous: "<", next: ">", first: "<<", last: ">>" }, zeroRecords: "", info: "", infoEmpty: "", infoFiltered: "", sSearch: ":", }, //在每次table被draw完后回调函数 fnDrawCallback: function(){ var api = this.api(); //获取到本页开始的条数    var startIndex= api.context[0]._iDisplayStart;    api.column(1).nodes().each(function(cell, i) {      cell.innerHTML = startIndex + i + 1;    }); } }); //查询按钮 「#btn-query").on("click", function () { tables.fnDraw();//查询后不需要保持分页状态,回首页 }); //添加 「#btn-add").on("click", function () { url = "<%=path%>/goodsType/add"; $("input[name=typeId]").val(0); $("input[name=typeNameCn]").val(""); $("input[name=typeNameEn]").val(""); 「#editModal」.modal("show"); }); //批量删除 「#btn-delAll").on("click", function () { }); // 「#btn-export\ }); //リフレッシュ 「#btn-re").on("click", function () {}} tables.fnDraw(false);//ページ状態を維持してリフレッシュ }); //チェックボックス全選択 「#checkAll」.on("click", function () { if ($(this).prop("checked") === true) { 「input[name='checkList']」.prop("checked", $(this).prop("checked")); //「#dataTable tbody tr」.addClass('selected'); $(this).hasClass('selected') } else { 「input[name='checkList']」.prop("checked", false); 「#dataTable tbody tr」.removeClass('selected'); } }); //編集 「#dataTable tbody」.on("click", "#editRow", function () { if(confirm("この情報を削除することを確認しますか?" 「input[name=typeId]」.val(data.typeIdStr); 「input[name=typeNameCn]」.val(data.typeNameCn); url = "<%=path%>/goodsType/update"; 「#editModal」.modal("show"); }); 「#btn-submit").on("click", function(){ url:'<%=path%> cache: false, type: "POST", url: url, data:「#editForm」.serialize(), async: false, error: function(request) { showFail("サーバー接続エラー..."); }, success: function(data) { { 1showSuccess("<sp:message code='sys.oper.success' 「#editModal」.modal("hide"); tables.api().row().remove().draw(false);/">); tables.fnDraw(); } showFail("<sp:message code='sys.oper.fail'/">); } } }); }); //削除 「#dataTable tbody」.on("click", "#delRow", function () { if(confirm("この情報を削除することを確認しますか?" ;")){63 url:'<%=path%> del/goodsType/"/data.typeIdStr,+type:'delete', dataType: "json", cache: "false", success:function(data){ if(data.status == { 1showSuccess("<sp:message code='sys.oper.success' tables.api().row().remove().draw(false);/">); else{ } showFail("<sp:message code='sys.oper.fail'/">); } }, error:function(err){ showFail("サーバー接続エラー..."); } }); } }); }); </script>

Javaコード

コントローラー処理メソッド、ページのテーブルデータをクエリし、JSON形式で返信する責任があります。

@RequestMapping(value="/goodsType/getData", produces = "text/json;charset=UTF-8")
@ResponseBody
public String getData(HttpServletRequest request, QueryCondition query) {
DatatablesView<GoodsType> dataTable = goodsTypeService.getGoodsTypeByCondition(query);
dataTable.setDraw(query.getDraw());
String data = JSON.toJSONString(dataTable);
return data;
}

返信Jsonデータ形式

{
"data": [{
"createTime": "2016-10-27 09:42:28.0",
"typeId": 96824775296417986,
"typeIdStr": "96824775296417986",
"typeNameCn": "食品",
"typeNameEn": "Foods",
"updateTime": "2016-10-28 13:00:24.0"
},
{
"createTime": "2016-10-27 09:42:27.0",
"typeId": 96824775296417979,
"typeIdStr": "96824775296417979",
"typeNameCn": "自動車"
"typeNameEn": "Cars123",
"updateTime": "2016-10-27 09:51:24.0"
}],
"draw": 1,
"recordsFiltered": 17,
"recordsTotal": 17
}

DatatablesViewは、DataTablesが必要とするフォーマット定義に基づいています

public class DatatablesView<T> { 
private List<T> data; //dataとdatatalesが読み込む「dataSrc」に対応しています 
private int recordsTotal; 
private int recordsFiltered; 
private int draw;
public DatatablesView() { 
}
public int getDraw() {
return draw;
}
public void setDraw(int draw) {
this.draw = draw;
}
public List<T> getData() {
return data;
}
public void setData(List<T> data) {
this.data = data;
}
public int getRecordsTotal() {
return recordsTotal;
}
public void setRecordsTotal(int recordsTotal) {
this.recordsTotal = recordsTotal;
this.recordsFiltered = recordsTotal;
}
public int getRecordsFiltered() {
return recordsFiltered;
}
public void setRecordsFiltered(int recordsFiltered) {
this.recordsFiltered = recordsFiltered;
} 
}

Serviceビジネス処理クラスは、主にクエリ条件に基づいてレコード数を統計し、現在のページデータリストをクエリします

public DatatablesView<GoodsType> getGoodsTypeByCondition(QueryCondition query) {
DatatablesView<GoodsType> dataView = new DatatablesView<GoodsType>();
//クエリ条件の構築
WherePrams where = goodsTypeDao.structureConditon(query);
Long count = goodsTypeDao.count(where);
List<GoodsType> list = goodsTypeDao.list(where);
dataView.setRecordsTotal(count.intValue());
dataView.setData(list);
return dataView;
}

Dao層は基本的なデータベースクエリ操作であり、ここでは省略しています...

終わり

検索条件では、キーワードのぼやけ検索のみを使用しており、ビジネスの需要に応じて、他の検索条件を動的に追加することができます。バックエンドでは、対応する処理を行う必要があります。

以下は、編集者が皆様に紹介するSpringMVCに基づく+SpringMVCに基づく+DataTablesでテーブルのサーバーサイドページネーション、ぼやけ検索を実現し、皆様に役立つことを願っています。何かご不明な点がございましたら、コメントを残してください。編集者は迅速に回答いたします。

声明:この記事の内容はインターネットから取得しており、著作権者は所有者であり、インターネットユーザーが自発的に貢献し、自己でアップロードしたものであり、このサイトは所有権を持ちません。また、人工的な編集は行われておらず、関連する法的責任も負いません。著作権に抵触する内容がある場合は、メールを送信して:notice#w までお知らせください。3codebox.com(メールを送信する際、#を@に変更してください)で通報し、関連する証拠を提供してください。一旦確認が取れましたら、このサイトは即座に侵害する可能性のある内容を削除します。

Elasticsearch 教程