paging 수정, DatasetControl.find(..), findAll(..) 추가

master
mjkhan21 4 months ago
parent 30f211adf0
commit 817f318dc5

@ -630,14 +630,16 @@ $.fn.setPaging = function(config) {
config.next = function(index, label) {return '<li onclick="{func}" class="page-item next"><a class="page-link"><i class="tf-icon bx bx-chevron-right"></i></a></li>'.replace(/{func}/, config.func.replace(/{index}/, label));}; config.next = function(index, label) {return '<li onclick="{func}" class="page-item next"><a class="page-link"><i class="tf-icon bx bx-chevron-right"></i></a></li>'.replace(/{func}/, config.func.replace(/{index}/, label));};
config.last = function(index, label) {return '<li onclick="{func}" class="page-item last"><a class="page-link"><i class="tf-icon bx bx-chevrons-right"></i></a></li>'.replace(/{func}/, config.func.replace(/{index}/, label));}; config.last = function(index, label) {return '<li onclick="{func}" class="page-item last"><a class="page-link"><i class="tf-icon bx bx-chevrons-right"></i></a></li>'.replace(/{func}/, config.func.replace(/{index}/, label));};
return this.each(function(){ return this.each(function(){
let length = config.list ? config.list.length : config.dataLength, let length = config.list ? config.list.length : config.dataLength,
empty = length < 1, empty = length < 1,
start = empty ? 0 : config.start + 1, start = empty ? 0 : config.start + 1,
end = empty ? 0 : config.start + length, end = empty ? 0 : config.start + length,
pagingInfo = empty ? "" : start + " ~ " + numberFormat.format(end) + " / " + numberFormat.format(config.totalSize); pagingInfo = empty ? "" : start + " ~ " + numberFormat.format(end) + " / " + numberFormat.format(config.totalSize),
selector = "#"+ config.prefix + "PagingInfo,[name='" + config.prefix + "PagingInfo']";
$("#"+ config.prefix + "PagingInfo").html(pagingInfo); $(selector).html(pagingInfo);
let tag = paginate(config), let tag = paginate(config),
container = $(this); container = $(this);
@ -647,7 +649,6 @@ $.fn.setPaging = function(config) {
if (config.hideIfEmpty != false) if (config.hideIfEmpty != false)
container.hide(); container.hide();
} }
}); });
} }
@ -658,9 +659,10 @@ $.fn.setPagingInfo = function(config) {
pagingInfo = empty ? "" : 1 pagingInfo = empty ? "" : 1
+ " ~ " + " ~ "
+ numberFormat.format(length) + numberFormat.format(length)
+ " / " + numberFormat.format(config.totalSize); + " / " + numberFormat.format(config.totalSize),
selector = "#"+ config.prefix + "PagingInfo,[name='" + config.prefix + "PagingInfo']";
$("#"+ config.prefix + "PagingInfo").html(pagingInfo); $(selector).html(pagingInfo);
}); });
} }

@ -1372,8 +1372,8 @@ class DatasetControl {
return this.dataset.getCurrent(option); return this.dataset.getCurrent(option);
} }
currentToObject() { toObject(item) {
return this.dataBinder().toObject(this.getCurrent("item")); return this.dataBinder().toObject(item || this.getCurrent("item"));
} }
dataBinder() { dataBinder() {
@ -1500,6 +1500,14 @@ class DatasetControl {
querySelectorAll(selector) { querySelectorAll(selector) {
return this.dataBinder().querySelectorAll(selector); return this.dataBinder().querySelectorAll(selector);
} }
find(name) {
return this.querySelector(!name.startsWith("#") ? "[name='" + name + "']" : name);
}
findAll(name) {
return this.querySelectorAll("[name='" + name + "']");
}
} }
var dataBinder = { var dataBinder = {
@ -1616,9 +1624,11 @@ var dataBinder = {
let result = {}; let result = {};
obj.inputs().forEach(input => { obj.inputs().forEach(input => {
let dataMap = dataBinder.dataMap(input), let dataMap = dataBinder.dataMap(input),
property = dataBinder.property(input) || dataMap; property = dataBinder.property(input) || dataMap,
value = item.data[dataMap || property];
result[property] = item.data[dataMap || property]; if (value !== undefined)
result[property] = value;
}); });
return result; return result;
} }

Loading…
Cancel
Save