Front/JS & jQuery

[jQuery] [datatables] columns.createdCell

오선지♬ 2022. 9. 5. 18:59
728x90
반응형

function(td, cellData, rowData, row, col)

,{ "targets" : [0,2,4,6],
  'createdCell': function(td,cellData,rowData,row,col){
      if(col == 0){
        $(td).html(`
            <div class="blue">${ cellData ? cellData : '' }</div>
            <div>${ rowData.ITEM_NM_10 ?  rowData.ITEM_NM_10 : '' }</div>
        `)
      }else if(col == 2){
        $(td).html(`
                <div class="blue">${ cellData ? cellData : '' }</div>
                <div>${ rowData.ITEM_NM_20 ?  rowData.ITEM_NM_20 : '' }</div>
            `)
      }else if(col == 4){
        $(td).html(`
                <div class="blue">${ cellData ? cellData : '' }</div>
                <div>${ rowData.ITEM_NM_30 ?  rowData.ITEM_NM_30 : '' }</div>
            `)
      }else if(col == 6){
        $(td).html(`
                <div class="blue">${ cellData ? cellData : '' }</div>
                <div>${ rowData.ITEM_NM_50 ?  rowData.ITEM_NM_50 : '' }</div>
            `)
      }
  }
}

https://datatables.net/reference/option/columns.createdCell

 

columns.createdCell

columns.createdCell Since: DataTables 1.10 Cell created callback to allow DOM manipulation. Description This is a callback function that is executed whenever a cell is created (Ajax source, etc) or read from a DOM source. It can be used as a complement to

datatables.net

 

 

728x90
반응형