Hi all,
So I just got my child row to work and it's fantastic! I even added the slider effect. I'm loving it.
So my challenge now is... I was trying out the one-to-many feature as explained here: https://editor.datatables.net/examples/advanced/joinArray.html I got that working, but I'd like to have each "access" or in my case "contact" to appear in the child row, but I can't figure out how.
I just need to know how to place
{ data: "contacts", render: "[, ].cname" }
into the javascript for
'<td>'+d.table.column+'</td>'+
I have the following:
server-side
<?php
// DataTables PHP library
include("../Editor-PHP-1.4.2/php/DataTables.php");
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
Editor::inst( $db, 'brand' )
->field(
Field::inst( 'brand.name' ),
Field::inst( 'brand.address' ),
Field::inst( 'brand.city' ),
Field::inst( 'brand.state' ),
Field::inst( 'brand.country' )
)
->join(
Join::inst( 'contacts', 'array' )
->join(
array( 'id', 'brand_id' ),
array( 'id', 'contact_id' ),
'brand_to_contacts'
)
->fields(
Field::inst( 'id' )->validator( 'Validate::required' )
->options( 'contacts', 'id', 'cname'),
Field::inst( 'cname' )
)
)
->process($_POST)
->json();
javascript for the child function
function format ( d ) {
// `d` is the original data object for the row
return '<div class="slider">'+ '<table cellpadding="5" cellspacing="0" border="0" style="padding-left:50px;">'+
'<tr>'+
'<td>Contact Name:</td>'+
'<td>'+d.???.????+'</td>'+
'</tr>'+
'</table>'+
'</div>';
}