How to add details-control to show child rows

How to add details-control to show child rows

lampamplampamp Posts: 8Questions: 3Answers: 1

Hello,
I'm trying to follow this example http://www.datatables.net/examples/api/row_details.html to display my child row details.
The problem is that I've noticed that in the example a 'details-control' column is defined at the beginning. In my situation I have the table ready with all the info (not from ajax) var table = jQuery('#igsv-MY_TABLE_KEY').DataTable(); so I can't define it as in the example, so all I need is to find a way to add a 'details-control' column at the beginning so that I'll have the "+" used to expand and show details.

I searched this forums as well but I couldn't find a simple way to add columns.

Thank you

Answers

  • lampamplampamp Posts: 8Questions: 3Answers: 1

    Any thoughts?
    All I need is to add this column
    { "className": 'details-control', "orderable": false, "data": null, "defaultContent": '' }
    to my table

  • AshbjornAshbjorn Posts: 55Questions: 2Answers: 16
    edited July 2015

    Hi lampamp,

    You can add custom columns and their content using the columnDefs property:

    $('#example').dataTable( {
      "columnDefs": [ {
          "targets": -1,
          "data": null,
          "orderable": false,
          "className": 'details-control',
          "defaultContent": ''
        } ]
    } );
    

    Additionally you may wish to check out this page: Generated content for a column

    Hope this helps,

This discussion has been closed.