How do Child rows (extra show / detailed information) move to another table?

How do Child rows (extra show / detailed information) move to another table?

rrzavaletarrzavaleta Posts: 78Questions: 52Answers: 2
edited November 2014 in DataTables

Is possible to send the content to another table to the children of a master table ?
in the example.

hen you click on the sig + the contents to another table vande . plss to need example.

im usign http://localhost/DataTables-1.10.4/DataTables-1.10.4/examples/api/row_details.html

$(document).ready(function() {
var table = $('#example').DataTable( {
"ajax": "include/generadorcentradobusqueda.php",
"columns": [
{
"class": 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "NOM_CAMPO" },
{ "data": "TXT_ETIQUETA" },

    ]
} );

// Add event listener for opening and closing details
$('#example tbody').on('click', 'td.details-control', function () {
    var tr = $(this).closest('tr');
    var row = table.row( tr );

    if ( row.child.isShown() ) {
        // This row is already open - close it
        row.child.hide();
        tr.removeClass('shown');
    }
    else {
        // Open this row
        row.child( format(row.data()) ).show();
        tr.addClass('shown');
    }
} );

} );

  <table id="example" class="display" cellspacing="0" width="100%">
            <thead>
                <tr>
                    <th></th>
                    <th>Name</th>
                    <th>Position</th>

              </tr>
            </thead>

    <tfoot>
                <tr>
                    <th></th>
                    <th>Name</th>
                    <th>Position</th>

      </tr>
    </tfoot>
  </table>
  <table id="example2" class="display" cellspacing="0" width="100%">

            <tbody>
            </tbody>
  </table>

Answers

  • allanallan Posts: 63,576Questions: 1Answers: 10,483 Site admin

    You can't pass the row as such, but I don't see any reason why data couldn't be passed around. You would read the data from the host row using row().data() and then do whatever action is required to pass it to the second table. row().data() can be used to update a row, or row.add() to add a new row for example.

    Allan

This discussion has been closed.