PureJS 구 버전 CustomGridEditor를 여러번 적용할 경우 핸들러 과적용으로 오류 발생
페이지 정보
작성자 tommy 작성일 2024-01-11 11:50 조회 72회 댓글 0건본문
관련링크
https://dev.mescius.co.kr/bbs/board.php?bo_table=wijmo_qna&wr_id=3130
지난 번에 알려주신 기능으로 readOnly는 잘 적용이 되었습니다.
그런데 필터/권한을 함수로 구현하고 버튼 클릭 시 적용하는 기능이 있습니다.
그래서 불가피하게 CustomGridEditor가 여러번 적용됩니다.
이 경우 핸들러가 너무 많이 생성되어 CustomGridEditor에서 오류가 발생합니다.
오류 재현은 지난 번에 알려주신 codepen 예제에서 addEditors(); 함수를 여러번 호출하면 발생합니다.
챗gpt는 dispose 기능을 구현하라고 하는데, 잘 안되어서 질문 드립니다.
아래 챗gpt가 작성한 소스코드를 참고로 첨부합니다.
if (column.format === 'd') { if (column.customEditor) { column.customEditor.dispose(); // Dispose method to be implemented in CustomGridEditor } column.customEditor = new CustomGridEditor(theGrid, column.binding, wijmo.input.InputDate, { format: 'd', isRequired: false, value: null }); }
CustomGridEditor.prototype.dispose = function() { // Remove event handlers from the grid if (this._grid && this._handlersAdded) { this._grid.beginningEdit.removeHandler(this._beginningEditHandler); this._grid.sortingColumn.removeHandler(this._commitRowEditsHandler); this._grid.scrollPositionChanged.removeHandler(this._scrollPositionChangedHandler); this._grid.selectionChanging.removeHandler(this._selectionChangingHandler); this._grid.lostFocus.removeHandler(this._gridLostFocusHandler); } // Remove event handlers from the control if (this._ctl) { this._ctl.removeEventListener('keydown', this._keydownHandler, this._ctl.hostElement); this._ctl.lostFocus.removeHandler(this._lostFocusHandler); if (this._ctl.dispose) { this._ctl.dispose(); } } // Remove event handler for window resize window.removeEventListener('resize', this._resizeHandler); // Clear references this._grid = null; this._col = null; this._ctl = null; this._handlersAdded = false; };
댓글목록
등록된 댓글이 없습니다.