IT tech Coding/javascript
tui grid input값 null이 자꾸 나와서 짜증날때?
Coding Life
2023. 3. 8. 09:56
반응형
toast grid에서 input값을 넣을때 자꾸 null이 찍혀서 짜증날때 간편 해결법이 있습니다.
위의 증상이죠.
기본 CustomTextEditor 의 내용을 일부 수정하는 것인데요,
class CustomTextEditor {
constructor(props) {
const el = document.createElement('input');
const {maxLength} = props.columnInfo.editor.options;
el.type = 'text';
el.maxLength = maxLength;
el.value = String(props.value);
this.el = el;
}
getElement() {
return this.el;
}
getValue() {
return this.el.value;
}
mounted() {
this.el.select();
}
}
수정하면 ?
class CustomTextEditor {
constructor(props) {
const el = document.createElement('input');
const {maxLength} = props.columnInfo.editor.options;
el.type = 'text';
el.maxLength = maxLength;
el.value = String(props.value ? props.value: "");
this.el = el;
}
getElement() {
return this.el;
}
getValue() {
return this.el.value;
}
mounted() {
this.el.select();
}
}
기존 코드 : el.value = String(props.value);
이것을 수정해서 : el.value = String(props.value ? props.value: "");
이렇게 되면 되네요^^
반응형