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 389 forks source link

use Pagination dataSource without edit to backend source #1619

Open Cronian opened 2 years ago

Cronian commented 2 years ago

Summary use tui-pagination dataSource without edit to backend source, how can i change dataform before run parsing

Version grid : 4.13.0 pagination : 3.4.0

Additional context when i use tui-pagination with dataSource, i must change backend dataform.

but it can’t.

how can i change dataform without edit to backend source.

——————————————————————

Toast Pagination에서 dataSource 사용시 지정된 형태로 결과 데이터를 넘겨주어야 정상 동작하지만

백앤드의 데이터 형태를 바꿀 수 없는 경우라서 api:readData에서 response를 처리하기 전에 response의 데이터 형태를 바꿔주려고 합니다.

이 경우 라이브러리 소스를 직접 수정하지 않고 response의 형태를 변경시켜줄 방법이 있을까요?

아래는 직접 시도해본 방법들입니다.

  1. dataSource를 사용하지 않고 직접 grid에 row를 그려주고 pageOption값을 설정해준다
    • 이 경우 페이징의 네비게이션 바에서 번호 클릭 시 이벤트가 동작하지 않습니다. ( 데이터 소스에 api를 구현해야 한다고 오류발생 )
  2. grid.on('response',ev => {}); 를 통해 응답 시 먼저 데이터를 받아 ev.xhr.response 와 ev.xhr.responseText의 값을 변경해준다.
    • 이 경우 ev.xhr.response와 ev.xhr.responseText의 값이 변경불가로 되어있어 정상적으로 수정되지 않습니다. ( Object.defineProperty 를 통해 변경해보려 했으나 정상적으로 수정되지 않았습니다.)
jajugoguma commented 2 years ago

@Cronian Have you tried editing ev.xhr.res._body?

Cronian commented 2 years ago

@Cronian Have you tried editing ev.xhr.res._body?

in my case, ev.xhr.res is not exist.. (Spring framework 4.3.29 & Tomcat 9.0)

stale[bot] commented 2 years 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!

stale[bot] commented 1 year ago

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