그리드 셀 클릭 이벤트 오류 수정
This commit is contained in:
@@ -178,6 +178,15 @@ function createSelect2Editor(options) {
|
||||
var container = document.createElement("span");
|
||||
var select = document.createElement("select");
|
||||
select.style.width = "100%";
|
||||
var isCompleted = false;
|
||||
|
||||
function onComplete(val) {
|
||||
if(isCompleted) return;
|
||||
isCompleted = true;
|
||||
$(document).off('mousedown.select2Editor');
|
||||
try { $(select).select2('close'); $(select).select2('destroy'); } catch(e) {}
|
||||
success(val);
|
||||
}
|
||||
|
||||
// 빈 옵션 추가
|
||||
var emptyOption = document.createElement("option");
|
||||
@@ -209,7 +218,7 @@ function createSelect2Editor(options) {
|
||||
dropdownAutoWidth: true,
|
||||
placeholder: '선택',
|
||||
allowClear: true,
|
||||
dropdownParent: $('body'), // 드롭다운이 셀 밖으로 나오도록
|
||||
dropdownParent: $('body'),
|
||||
templateResult: function(data) {
|
||||
return data.text;
|
||||
},
|
||||
@@ -219,11 +228,15 @@ function createSelect2Editor(options) {
|
||||
});
|
||||
|
||||
$(select).on('select2:select select2:clear', function(e) {
|
||||
success($(select).val() || null);
|
||||
onComplete($(select).val() || null);
|
||||
});
|
||||
|
||||
$(select).on('select2:close', function(e) {
|
||||
// 포커스 잃었을 때 처리
|
||||
// 외부 클릭 시 mousedown 단계에서 먼저 에디터 종료 (클릭이 타겟 셀까지 전달되도록)
|
||||
$(document).on('mousedown.select2Editor', function(e) {
|
||||
if(!$(e.target).closest('.select2-container').length &&
|
||||
!$(e.target).closest('.select2-dropdown').length) {
|
||||
onComplete($(select).val() || null);
|
||||
}
|
||||
});
|
||||
|
||||
// Select2 열기
|
||||
@@ -606,6 +619,16 @@ function fn_initGrid() {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if(!data.SIZE) {
|
||||
// 규격 삭제 시 소재품번, 소재소요량, 소재발주수량 초기화
|
||||
row.update({
|
||||
RAW_MATERIAL_NO: '',
|
||||
PART_UNIT_QTY: 0,
|
||||
PART_UNIT_LENGTH: 0,
|
||||
REQUIRED_QTY: 0,
|
||||
ORDER_QTY: 0
|
||||
});
|
||||
row.reformat();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -343,7 +343,14 @@ function fn_initGrid() {
|
||||
input.style.boxSizing = "border-box";
|
||||
input.style.textAlign = "center";
|
||||
input.value = cell.getValue() || '';
|
||||
//input.placeholder = "YYYY-MM-DD";
|
||||
var isCompleted = false;
|
||||
|
||||
function onComplete(val) {
|
||||
if(isCompleted) return;
|
||||
isCompleted = true;
|
||||
try { $(input).datepicker("hide"); $(input).datepicker("destroy"); } catch(e) {}
|
||||
success(val);
|
||||
}
|
||||
|
||||
onRendered(function() {
|
||||
$(input).datepicker({
|
||||
@@ -351,20 +358,18 @@ function fn_initGrid() {
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
onSelect: function(dateText) {
|
||||
success(dateText);
|
||||
onComplete(dateText);
|
||||
},
|
||||
onClose: function() {
|
||||
onComplete(input.value);
|
||||
}
|
||||
});
|
||||
input.focus();
|
||||
input.select();
|
||||
});
|
||||
|
||||
input.addEventListener("blur", function() {
|
||||
if(!$(input).datepicker("widget").is(":visible")) {
|
||||
success(input.value);
|
||||
}
|
||||
});
|
||||
input.addEventListener("keydown", function(e) {
|
||||
if(e.keyCode === 13) success(input.value);
|
||||
if(e.keyCode === 13) { e.preventDefault(); onComplete(input.value); }
|
||||
if(e.keyCode === 27) cancel();
|
||||
});
|
||||
return input;
|
||||
|
||||
Reference in New Issue
Block a user