From 4a547f41aaa27dd394156c57440ee1e98a926f6b Mon Sep 17 00:00:00 2001 From: jjh Date: Fri, 25 Aug 2023 18:01:47 +0900 Subject: [PATCH] =?UTF-8?q?datatable=20=EC=8A=A4=ED=81=AC=EB=A1=A4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WEB-INF/jsp/fims/excl/excl01010-main.jsp | 13 ++++- .../WEB-INF/jsp/fims/excl/excl02010-main.jsp | 54 +++++++++++------- .../WEB-INF/jsp/fims/excl/excl03010-main.jsp | 57 +++++++++++-------- 3 files changed, 77 insertions(+), 47 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/fims/excl/excl01010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/excl/excl01010-main.jsp index 5b0135bf..a5a32128 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/excl/excl01010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/excl/excl01010-main.jsp @@ -468,10 +468,19 @@ }); // DataTables 스크롤 이벤트 - $("#table-responsive--${pageName}").scroll(function() { + $("#table-responsive--${pageName}").scroll(function(obj) { let el = $(this); - if (el.scrollTop() == 0) return; + if (el.scrollTop() == 0) { + return; + } + + let itemsCnt = ${pageName}Control.dataset._items.length; + let totCnt = ${pageName}Control.dataset.getCurrent("item").data.TOT_CNT; + + if (itemsCnt >= totCnt) { + return; + } if ((el[0].scrollHeight - el.scrollTop() + VERTICAL_SCROLL_HEIGHT) <= el.outerHeight()) { ${pageName}Control.load(${pageName}Control.query.pageNum + 1); diff --git a/src/main/webapp/WEB-INF/jsp/fims/excl/excl02010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/excl/excl02010-main.jsp index 09c0a72f..05c9e4f6 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/excl/excl02010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/excl/excl02010-main.jsp @@ -417,6 +417,27 @@ }); } + /************************************************************************** + * + **************************************************************************/ + // DataTables에 click, dbclick 이벤트 + renderList${pageName} = () => { + let ${infoPrefix}List = ${pageName}Control.dataset; + let empty = ${infoPrefix}List.empty; + + let trs = empty ? + [document.getElementById("${infoPrefix}NotFound--${pageName}").innerHTML] : <%-- from template#${infoPrefix}NotFound --%> + ${infoPrefix}List.inStrings( + document.getElementById("${infoPrefix}Row--${pageName}").innerHTML, <%-- from template#${infoPrefix}Row --%> + (str, dataItem) => str + .replace(/{onclick}/gi, "${pageName}Control.setCurrent('" + dataItem.getValue("OPNN_ID") + "');") + .replace(/{ondblclick}/gi, "${pageName}Control.getTotalInfo('" + dataItem.getValue("CRDN_ID") + "');") + ); + + $("#tbody--${pageName}").html(trs.join()); + $("th input[type='checkbox']").prop("checked", false); + } + /************************************************************************** * 초기 셋팅 **************************************************************************/ @@ -447,33 +468,24 @@ }); // DataTables 스크롤 이벤트 - $("#table-responsive--${pageName}").scroll(function() { + $("#table-responsive--${pageName}").scroll(function(obj) { let el = $(this); - if (el.scrollTop() == 0) return; - - if ((el[0].scrollHeight - el.scrollTop() + VERTICAL_SCROLL_HEIGHT) <= el.outerHeight()) { - fnBtnSearchList${pageName}(${pageName}Control.query.pageNum + 1); + if (el.scrollTop() == 0) { + return; } - }); - } - // DataTables에 click, dbclick 이벤트 - function renderList${pageName}() { - let ${infoPrefix}List = ${pageName}Control.dataset; - let empty = ${infoPrefix}List.empty; + let itemsCnt = ${pageName}Control.dataset._items.length; + let totCnt = ${pageName}Control.dataset.getCurrent("item").data.TOT_CNT; - let trs = empty ? - [document.getElementById("${infoPrefix}NotFound--${pageName}").innerHTML] : <%-- from template#${infoPrefix}NotFound --%> - ${infoPrefix}List.inStrings( - document.getElementById("${infoPrefix}Row--${pageName}").innerHTML, <%-- from template#${infoPrefix}Row --%> - (str, dataItem) => str - .replace(/{onclick}/gi, "${pageName}Control.setCurrent('" + dataItem.getValue("OPNN_ID") + "');") - .replace(/{ondblclick}/gi, "${pageName}Control.getTotalInfo('" + dataItem.getValue("CRDN_ID") + "');") - ); + if (itemsCnt >= totCnt) { + return; + } - $("#tbody--${pageName}").html(trs.join()); - $("th input[type='checkbox']").prop("checked", false); + if ((el[0].scrollHeight - el.scrollTop() + VERTICAL_SCROLL_HEIGHT) <= el.outerHeight()) { + ${pageName}Control.load(${pageName}Control.query.pageNum + 1); + } + }); } /************************************************************************** diff --git a/src/main/webapp/WEB-INF/jsp/fims/excl/excl03010-main.jsp b/src/main/webapp/WEB-INF/jsp/fims/excl/excl03010-main.jsp index 812f6853..ea74fff6 100644 --- a/src/main/webapp/WEB-INF/jsp/fims/excl/excl03010-main.jsp +++ b/src/main/webapp/WEB-INF/jsp/fims/excl/excl03010-main.jsp @@ -314,9 +314,6 @@ }); } - /************************************************************************** - * - **************************************************************************/ // 저장 callback ${pageName}Control.onSave = (resp) => { if (resp.saved) @@ -334,6 +331,27 @@ }); } + /************************************************************************** + * + **************************************************************************/ + // DataTables에 click, dbclick 이벤트 + renderList${pageName} = () => { + let ${infoPrefix}List = ${pageName}Control.dataset; + let empty = ${infoPrefix}List.empty; + + let trs = empty ? + [document.getElementById("${infoPrefix}NotFound--${pageName}").innerHTML] : <%-- from template#${infoPrefix}NotFound --%> + ${infoPrefix}List.inStrings( + document.getElementById("${infoPrefix}Row--${pageName}").innerHTML, <%-- from template#${infoPrefix}Row --%> + (str, dataItem) => str + .replace(/{onclick}/gi, "${pageName}Control.setCurrent('" + dataItem.getValue("RE_REG_ID") + "');") + .replace(/{ondblclick}/gi, "${pageName}Control.getTotalInfo('" + dataItem.getValue("CRDN_ID") + "');") + ); + + $("#tbody--${pageName}").html(trs.join()); + $("th input[type='checkbox']").prop("checked", false); + } + /************************************************************************** * 초기 셋팅 **************************************************************************/ @@ -363,33 +381,24 @@ }); // DataTables 스크롤 이벤트 - $("#table-responsive--${pageName}").scroll(function() { + $("#table-responsive--${pageName}").scroll(function(obj) { let el = $(this); - if (el.scrollTop() == 0) return; - - if ((el[0].scrollHeight - el.scrollTop() + VERTICAL_SCROLL_HEIGHT) <= el.outerHeight()) { - fnBtnSearchList${pageName}(${pageName}Control.query.pageNum + 1); + if (el.scrollTop() == 0) { + return; } - }); - } - // DataTables에 click, dbclick 이벤트 - function renderList${pageName}() { - let ${infoPrefix}List = ${pageName}Control.dataset; - let empty = ${infoPrefix}List.empty; + let itemsCnt = ${pageName}Control.dataset._items.length; + let totCnt = ${pageName}Control.dataset.getCurrent("item").data.TOT_CNT; - let trs = empty ? - [document.getElementById("${infoPrefix}NotFound--${pageName}").innerHTML] : <%-- from template#${infoPrefix}NotFound --%> - ${infoPrefix}List.inStrings( - document.getElementById("${infoPrefix}Row--${pageName}").innerHTML, <%-- from template#${infoPrefix}Row --%> - (str, dataItem) => str - .replace(/{onclick}/gi, "${pageName}Control.setCurrent('" + dataItem.getValue("RE_REG_ID") + "');") - .replace(/{ondblclick}/gi, "${pageName}Control.getTotalInfo('" + dataItem.getValue("CRDN_ID") + "');") - ); + if (itemsCnt >= totCnt) { + return; + } - $("#tbody--${pageName}").html(trs.join()); - $("th input[type='checkbox']").prop("checked", false); + if ((el[0].scrollHeight - el.scrollTop() + VERTICAL_SCROLL_HEIGHT) <= el.outerHeight()) { + ${pageName}Control.load(${pageName}Control.query.pageNum + 1); + } + }); } /**************************************************************************