Making primary key link to child relationship table
Making primary key link to child relationship table
Hello,
How to make datatables in its primary key column be a link to the relationship table? here is my code:
index.blade.php:
<script type="text/javascript">
var oTable;
$(document).ready(function() {
oTable = $('#jmats').dataTable( {
"sDom": "<'row'<'col-md-6'l><'col-md-6'f>r>t<'row'<'col-md-6'i><'col-md-6'p>>",
"sPaginationType": "bootstrap",
"oLanguage": {
"sLengthMenu": "_MENU_ data per halaman"
},
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{{ URL::to('admin/jmats/data') }}",
"fnDrawCallback": function ( oSettings ) {
$(".iframe").colorbox({iframe:true, width:"80%", height:"80%"});
}
});
});
</script>
Controller:
public function getData()
{
$jmats = Jmat::select(array('jmats.kdjmat', 'jmats.keterangan'));
return Datatables::of($jmats)
->add_column('actions', '
<div class="btn-group">
<a href="{{{ URL::to(\'admin/jmats/\' . $kdjmat . \'/edit\' ) }}}" class="btn btn-primary btn-xs iframe" ><i class="fa fa-pencil"></i> {{{ Lang::get(\'button.edit\') }}}</a> <a href="{{{ URL::to(\'admin/jmats/\' . $kdjmat . \'/delete\' ) }}}" class="btn btn-xs btn-danger iframe"><i class="fa fa-trash-o"></i> {{{ Lang::get(\'button.delete\') }}}</a>
</div>
')
->remove_column('rn') // rownum for oracle
->make();
}
thanks in advance