feat: 암석시험정보 > 삼축압축에서 값 입력시, 딜레이현상 수정

main
thkim 2026-03-26 11:45:34 +09:00
parent 25496d0f0c
commit ce4175e783
2 changed files with 88 additions and 79 deletions

View File

@ -408,16 +408,15 @@ function removeItemAt() {
//그리드 col수 이벤트
function fn_rowChange(){
var grid = kendoJQuery("#kictGrid").data("kendoGrid");
var dataSource = grid.dataSource;
var data = dataSource.data();
var dataSource = grid.dataSource;
// 1. 현재 정보 파악
var currentColumns = grid.columns.slice(); // 기존 컬럼 배열 복사
var baseColCount = 3; // TITLE1, TITLE2, COLUMN (고정 컬럼 수)
var nowColLength = currentColumns.length - baseColCount;
var nowColLength = grid.columns.length - 3; // 타이틀 & COLUMN 수 제외
var nowRowLength = grid.dataSource.options.data.length
var nowColCount = nowColLength;
var nowRowCount = nowRowLength;
//입력한 수
var cnt = $("#GridRowCnt").val();
var cnt = Number($("#GridRowCnt").val()) || 0;
cnt = Number(cnt); // number로 형변환
if(cnt == null || cnt == ""){
cnt = 0;
@ -432,7 +431,7 @@ function fn_rowChange(){
if(cnt == 0){
alert("1건 이상 입력하세요.");
$("#GridRowCnt").val(nowColCount-2);
$("#GridRowCnt").val(1);
$("#GridRowCnt").focus();
return false;
}
@ -440,48 +439,46 @@ function fn_rowChange(){
myFields = grid.dataSource.options.schema.model.fields;
if( cnt >= nowColLength ){
var nowColCount = cnt - nowColLength
// 2. 컬럼 배열 재구성
if (cnt > nowColLength) {
// 추가가 필요한 만큼 루프
var addCount = cnt - nowColLength;
for (var i = 1; i <= addCount; i++) {
var newIdx = nowColLength + i;
currentColumns.push({
field: "VALUE" + newIdx,
editor: chooseEditor
});
}
} else if (cnt < nowColLength) {
// 삭제가 필요한 만큼 제거 (최소 1개 유지 조건 등 추가 가능)
var removeCount = nowColLength - cnt;
for (var i = 0; i < removeCount; i++) {
currentColumns.pop();
}
} else {
return; // 변경 사항 없음
}
var fieldsAdd = new Object();
var optionAdd = new Object();
// 3. setOptions를 단 한 번 호출하여 그리드 전체 갱신
// 이 과정에서 Kendo가 HTML과 내부 객체를 모두 동기화합니다.
grid.setOptions({
columns: currentColumns
});
for (var i = 1; i < nowColCount + 1; i++) {
var nowColCountAdd = nowColLength + i
var nowColCountVALUE = 'VALUE' + nowColCountAdd;
grid.setOptions({
columns: grid.columns.concat([
{ field: nowColCountVALUE, editor: chooseEditor }
])
});
for (var j = 0; j < nowRowCount; j++) {
dataSource.data()[j].set(nowColCountVALUE, 0);
if (grid.dataSource.options.data[j].COLUMN === "TEST_ORDER") {
dataSource.data()[j].set(nowColCountVALUE, nowColCountAdd)
} else if (grid.dataSource.options.data[j].COLUMN === "RTRI_REMARK") {
dataSource.data()[j].set(nowColCountVALUE, " ")
}
}
}
optionAdd = {"editable": true, "defaultValue": 0, nullable: true};
fieldsAdd[nowColCountVALUE] = optionAdd;
myFields[nowColCountVALUE] = optionAdd;
} else {
var nowColCount = nowColLength - cnt
if( nowColCount == 3 ) { // 타이틀 & COLUMN & 첫번째 VALUE 수 제외
return false;
} else {
for (var i = 0; i < nowColCount; i++) {
grid.columns.pop();
kendoJQuery("#kictGrid").find("tr td:nth-last-child(1)").each(function(){
kendoJQuery(this).remove();
});
}
}
}
// 4. 데이터 세팅 (필요시)
// setOptions 후에는 데이터 소스를 다시 체크하여 신규 컬럼에 기본값 할당
var newData = dataSource.data();
for (var j = 0; j < newData.length; j++) {
for (var k = 1; k <= cnt; k++) {
var colName = "VALUE" + k;
if (newData[j][colName] === undefined) {
newData[j].set(colName, 0); // 기본값 0 세팅
if (newData[j].COLUMN === "TEST_ORDER") newData[j].set(colName, k);
if (newData[j].COLUMN === "RTRI_REMARK") newData[j].set(colName, " ");
}
}
}
}
/* 도움말 시작 */
@ -677,18 +674,19 @@ function fn_openClipReport2(table,project,hole,sample,etc1,etc2,gbn){
function onEdit(e) {
var data = e.model;
if (data.COLUMN === "TEST_ORDER") {
this.closeCell();
}
e.preventDefault();
if (data.COLUMN === "TEST_ORDER") {
this.closeCell();
return;
}
// input focus select 옵션
var input = e.container.find("input");
input.focus(function (e) {
setTimeout(function () {
input.select();
});
});
// 에디터 활성화 시 즉시 선택 로직
var input = e.container.find("input.k-input");
if (input.length > 0) {
// Kendo 포맷팅 처리가 끝난 직후에 select가 실행되도록 딜레이 조정
setTimeout(function () {
input.select();
}, 1);
}
}
function fn_kendoGrid() {

View File

@ -14,24 +14,35 @@ function textEditor(container, options) {
// 입력 type number로 변경
function numericEditor(container, options, isHyphenAllowed = false) {
/*kendoJQuery('<input name="' + options.field + '" id="numeric-min-max" class="numeric-max-width-200" min="0" max="9999" />')*/
kendoJQuery('<input name="' + options.field + '" id="numeric-min-max" />')
.appendTo(container)
.kendoNumericTextBox({
format : "n20",
decimals: 20,
round: false,
//restrictDecimals: true,
change: function (e) {
if (e.sender.value() == null) {
options.model.set("result", null);
} else {
options.model.set("result", e.sender.value());
}
}
})
// NumericTextBox from 텍스트 길이 제한
//numericLengthControl();
// 1. 하이픈 허용 여부에 따라 타입을 결정합니다.
// 하이픈을 문자로서 입력받으려면 'text' 타입이 필요합니다.
var inputType = isHyphenAllowed ? "text" : "number";
var input = kendoJQuery('<input type="' + inputType + '" step="any" name="' + options.field + '" class="k-textbox" style="width:100%; text-align:right;" />');
input.appendTo(container)
.val(options.model[options.field])
.on("focus", function() {
this.select();
})
.on("blur", function() {
var valStr = this.value.trim();
// 2. 하이픈 허용인 경우 '-' 입력을 그대로 모델에 저장합니다.
if (isHyphenAllowed && valStr === "-") {
options.model.set(options.field, "-");
// 기존 common.js 로직에 따라 result 값도 세팅이 필요하다면 아래 추가
// options.model.set("result", "-");
} else {
// 숫자로 변환하여 모델에 저장
var valNum = parseFloat(valStr);
var finalVal = isNaN(valNum) ? null : valNum;
options.model.set(options.field, finalVal);
// options.model.set("result", finalVal); // 필요시 추가
}
});
input.focus();
}