728x90
반응형
EX)
,columns : [
•••
{data : "REG_DT",
render : function(data){
const year = data.substring(0,4);
const month = data.substring(5,7);
const day = data.substring(8,10);
const regdate = year+'.'+month+'.'+day;
return regdate
}},
•••
]
컬럼명이 "REG_DT"으로 들어오는 데이터 형태가 "yyyy-mm-dd"이었는데,
원하는 출력값은 "yyyy.mm.dd" 이서 데이터를 다시 처리해주어야 했다.
위의 예와 같이 datatables의 option중에서 columns 에서 데이터를 작성해주고,
render속성을 이용하여 데이터를 다시 렌더링 해줄 수 있다.
return값으로 화면에 출력된다.
원래 columnDefs 옵션을 사용해서 데이터 렌더링을 했었는데 위와 같은 방법도 있어서 사용해 보았다.
render: function(data, type, row, meta) {
}
data뿐만아니라 type, row, meta에 관해서도 작업해줄 수 있다.
https://datatables.net/examples/basic_init/data_rendering.html
DataTables example - Data rendering
Data rendering Data within DataTables can be easily rendered to add graphics or colour to your tables, as demonstrated in the example on this page. These examples make use of columns.render to customise the cells in three ways: A flag is added to the Offic
datatables.net
728x90
반응형
'Front > JS & jQuery' 카테고리의 다른 글
[jQuery] 동적으로 selectbox만들기 , selected 속성 추가하기 (0) | 2022.05.11 |
---|---|
[echarts] 차트 여러 개 그리기 (0) | 2022.05.09 |
[javascript] 자바스크립트 배열의 특징 (0) | 2022.05.07 |
[javascript] json배열의 키 값 구하기 - Object.keys() (0) | 2022.05.04 |
[javascript] 배열생성 (0) | 2022.05.03 |