|
|
|
|
@ -67,21 +67,32 @@ class TableSupport extends DatasetSupport {
|
|
|
|
|
|
|
|
|
|
if (this.tr) {
|
|
|
|
|
let template = this.find(this.tr);
|
|
|
|
|
this.tr = (template || {}).innerHTML || "";
|
|
|
|
|
this.tr = (template || {}).innerHTML;
|
|
|
|
|
}
|
|
|
|
|
if (this.notFound) {
|
|
|
|
|
let template = this.find(this.notFound);
|
|
|
|
|
this.notFound = (template || {}).innerHTML || "";
|
|
|
|
|
this.notFound = (template || {}).innerHTML;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.tr && !this.notFound) {
|
|
|
|
|
let templates = this.findAll(this.selector + " template");
|
|
|
|
|
if (templates.length < 1)
|
|
|
|
|
log("WARNING: ", this.selector + " must have a template for a data row");
|
|
|
|
|
this.tr = (templates[0] || {}).innerHTML;
|
|
|
|
|
if (!this.tr)
|
|
|
|
|
throw this.selector + " must have a template for a data row";
|
|
|
|
|
this.notFound = (templates[1] || {}).innerHTML;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!this.notFound) {
|
|
|
|
|
let length = (this.tr.match(/<td/gi) || []).length,
|
|
|
|
|
name = this.ctrl.prefixName || "정보";
|
|
|
|
|
if (!name.endsWith("정보"))
|
|
|
|
|
name += " 정보";
|
|
|
|
|
|
|
|
|
|
this.notFound = '<tr><td valign="top" colspan="{length}" class="text-center">{name}를 찾지 못했습니다</td></tr>'
|
|
|
|
|
.replace(/{length}/g, length)
|
|
|
|
|
.replace(/{name}/g, name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.setLoadNext();
|
|
|
|
|
|
|
|
|
|
let sort = evt => {
|
|
|
|
|
@ -159,9 +170,11 @@ class TableSupport extends DatasetSupport {
|
|
|
|
|
if (!this.selectionToggler) return;
|
|
|
|
|
|
|
|
|
|
let toggler = this.find(this.selectionToggler);
|
|
|
|
|
if (toggler) {
|
|
|
|
|
toggler.checked = false;
|
|
|
|
|
toggler.disabled = empty;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**Handler called back on the current change event.
|
|
|
|
|
* @param {DataItem} item current DataItem
|
|
|
|
|
@ -220,6 +233,51 @@ TableSupport.cssClass = {
|
|
|
|
|
asc: "sort-asc",
|
|
|
|
|
desc: "sort-desc"
|
|
|
|
|
};
|
|
|
|
|
TableSupport.resizableColumns = table => {
|
|
|
|
|
if ("string" == typeof(table))
|
|
|
|
|
table = document.querySelector(table);
|
|
|
|
|
let cols = table.querySelectorAll('th');
|
|
|
|
|
|
|
|
|
|
cols.forEach(col => {
|
|
|
|
|
let resizer = document.createElement('div');
|
|
|
|
|
resizer.className = 'resizer';
|
|
|
|
|
col.appendChild(resizer);
|
|
|
|
|
|
|
|
|
|
let startX, startWidth;
|
|
|
|
|
|
|
|
|
|
resizer.addEventListener('mousedown', (e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
startX = e.pageX;
|
|
|
|
|
startWidth = col.offsetWidth;
|
|
|
|
|
|
|
|
|
|
document.body.style.cursor = 'col-resize';
|
|
|
|
|
document.body.style.userSelect = 'none';
|
|
|
|
|
|
|
|
|
|
// 마우스 이동 이벤트 리스너 추가
|
|
|
|
|
document.addEventListener('mousemove', onMouseMove);
|
|
|
|
|
document.addEventListener('mouseup', onMouseUp);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function onMouseMove(e) {
|
|
|
|
|
let width = startWidth + (e.pageX - startX);
|
|
|
|
|
if (width >= 50) { // 최소 너비 50px
|
|
|
|
|
if (col.style.width.endsWith("rem")) {
|
|
|
|
|
col.style.width = rem.fromPx(width);
|
|
|
|
|
} else {
|
|
|
|
|
col.style.width = width + 'px';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function onMouseUp() {
|
|
|
|
|
document.body.style.cursor = 'default';
|
|
|
|
|
document.body.style.userSelect = 'auto';
|
|
|
|
|
|
|
|
|
|
document.removeEventListener('mousemove', onMouseMove);
|
|
|
|
|
document.removeEventListener('mouseup', onMouseUp);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class CurrentDataSupport extends DatasetSupport {
|
|
|
|
|
constructor(conf) {
|
|
|
|
|
|