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수 이벤트 //그리드 col수 이벤트
function fn_rowChange(){ function fn_rowChange(){
var grid = kendoJQuery("#kictGrid").data("kendoGrid"); var grid = kendoJQuery("#kictGrid").data("kendoGrid");
var dataSource = grid.dataSource; var dataSource = grid.dataSource;
var data = dataSource.data();
// 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 cnt = Number($("#GridRowCnt").val()) || 0;
var nowRowLength = grid.dataSource.options.data.length
var nowColCount = nowColLength;
var nowRowCount = nowRowLength;
//입력한 수
var cnt = $("#GridRowCnt").val();
cnt = Number(cnt); // number로 형변환 cnt = Number(cnt); // number로 형변환
if(cnt == null || cnt == ""){ if(cnt == null || cnt == ""){
cnt = 0; cnt = 0;
@ -432,7 +431,7 @@ function fn_rowChange(){
if(cnt == 0){ if(cnt == 0){
alert("1건 이상 입력하세요."); alert("1건 이상 입력하세요.");
$("#GridRowCnt").val(nowColCount-2); $("#GridRowCnt").val(1);
$("#GridRowCnt").focus(); $("#GridRowCnt").focus();
return false; return false;
} }
@ -440,48 +439,46 @@ function fn_rowChange(){
myFields = grid.dataSource.options.schema.model.fields; myFields = grid.dataSource.options.schema.model.fields;
if( cnt >= nowColLength ){ // 2. 컬럼 배열 재구성
var nowColCount = cnt - nowColLength 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(); // 3. setOptions를 단 한 번 호출하여 그리드 전체 갱신
var optionAdd = new Object(); // 이 과정에서 Kendo가 HTML과 내부 객체를 모두 동기화합니다.
grid.setOptions({
columns: currentColumns
});
for (var i = 1; i < nowColCount + 1; i++) { // 4. 데이터 세팅 (필요시)
var nowColCountAdd = nowColLength + i // setOptions 후에는 데이터 소스를 다시 체크하여 신규 컬럼에 기본값 할당
var nowColCountVALUE = 'VALUE' + nowColCountAdd; var newData = dataSource.data();
grid.setOptions({ for (var j = 0; j < newData.length; j++) {
columns: grid.columns.concat([ for (var k = 1; k <= cnt; k++) {
{ field: nowColCountVALUE, editor: chooseEditor } var colName = "VALUE" + k;
]) if (newData[j][colName] === undefined) {
}); newData[j].set(colName, 0); // 기본값 0 세팅
for (var j = 0; j < nowRowCount; j++) { if (newData[j].COLUMN === "TEST_ORDER") newData[j].set(colName, k);
dataSource.data()[j].set(nowColCountVALUE, 0); if (newData[j].COLUMN === "RTRI_REMARK") newData[j].set(colName, " ");
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();
});
}
}
}
} }
/* 도움말 시작 */ /* 도움말 시작 */
@ -677,18 +674,19 @@ function fn_openClipReport2(table,project,hole,sample,etc1,etc2,gbn){
function onEdit(e) { function onEdit(e) {
var data = e.model; var data = e.model;
if (data.COLUMN === "TEST_ORDER") { if (data.COLUMN === "TEST_ORDER") {
this.closeCell(); this.closeCell();
} return;
e.preventDefault(); }
// input focus select 옵션 // 에디터 활성화 시 즉시 선택 로직
var input = e.container.find("input"); var input = e.container.find("input.k-input");
input.focus(function (e) { if (input.length > 0) {
setTimeout(function () { // Kendo 포맷팅 처리가 끝난 직후에 select가 실행되도록 딜레이 조정
input.select(); setTimeout(function () {
}); input.select();
}); }, 1);
}
} }
function fn_kendoGrid() { function fn_kendoGrid() {

View File

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