columnDefs for child rows

columnDefs for child rows

mosleymosley Posts: 8Questions: 4Answers: 0

Following the example at https://datatables.net/examples/api/row_details.html is there a way to change '1' and '0' to "Yes' and 'No' like can be done with the following code for a parent row?

columnDefs: [
   {
      render: function ( data, type, row )
      {
         if (data === '1')
         {
            return 'Yes';
         } else {
            return 'No';
         }
      },
      targets: [ 4, 5 ]
   },
]

This question has an accepted answers - jump to answer

Answers

  • glendersonglenderson Posts: 231Questions: 11Answers: 29
    Answer ✓

    You can do it exactly in the same manner,

    var result ="<div>"
    if (d.yourColumnName =="1") {
      result +="Yes"
    } else {
     result +="No"
    }
     result +="</div>"
    
    return result
    
  • mosleymosley Posts: 8Questions: 4Answers: 0

    So simple when you put it like that. Thank you.

This discussion has been closed.