nhn / tui.grid

🍞🔡 The Powerful Component to Display and Edit Data. Experience the Ultimate Data Transformer!
http://ui.toast.com/tui-grid/
MIT License
2.42k stars 394 forks source link

moveRow script error #1777

Closed jalim12 closed 1 year ago

jalim12 commented 2 years ago

An error occurs when running the code below. Please tell me the solution. (This is the code to move the selected row down.)

  1. Add 2 rows
  2. Add a row by checking 2 rows (added below the check row)
  3. Error when moving down

아래 코드 실행 시 오류발생합니다. 해결방안을 알려주세요. 선택한 행을 아래로 이동하는 코드입니다.

  1. 행 2개를 추가
  2. 행 2개 check하여 행 추가 (check행 하위에 추가됨)
  3. 아래로 이동 시 에러

version: 4.21.3

const checkedRowKeys = grid.getCheckedRowKeys();
if (checkedRowKeys == null || checkedRowKeys.length == 0) return;

const reversed = [...checkedRowKeys].reverse();
reversed.forEach((rowKey, index, array) => {
    const rowIndex = grid.getIndexOfRow(rowKey);
    const afterRow = grid.getRowAt(rowIndex+1);
    if(!afterRow || array.includes(afterRow.rowKey)) return;

    grid.moveRow(rowKey, rowIndex + 1);   // error!
});

script console error: Uncaught TypeError: Cannot convert undefined or null to object at Function.keys () at _loop_1 (utils.js:69:8) at Object.fitRowHeightWhenMovingRow (utils.js:69:8) at Object.moveRow (input.js:21:3) at Grid.dispatch (utils.js:69:8) at Grid.moveRow (utils.js:69:8)

stale[bot] commented 1 year ago

This issue has been automatically marked as inactive because there hasn’t been much going on it lately. It is going to be closed after 7 days. Thanks!

stale[bot] commented 1 year ago

This issue will be closed due to inactivity. Thanks for your contribution!