Use my own function on datatables server side

Use my own function on datatables server side

pippuccio76pippuccio76 Posts: 19Questions: 10Answers: 0
edited December 2017 in Free community support

HI at all, sorry for english, i have problem woith large amount of data i want use my own function on datatable but something dont work .I include my classes and try to call the function method for example :

This is client side datatable :

<td>

           <a href='crea_corse_autista_interno.php?id=<?=$row['id_corse_autista_interno']?>' class='btn btn-primary btn-xs'><i class='fa fa-pencil'></i></a>
           <a href='elimina_corse_autista_interno.php?id=<?=$row['id_corse_autista_interno']?>' class='btn btn-danger btn-xs' onClick="return confirm('Sei sicuro di voler eliminare il record?');"><i class='fa fa-trash-o'></i></a>

           <a href='duplica_corsa.php?id=<?=$row['id_corse_autista_interno']?>' class='btn btn-primary btn-xs'><i class='fa fa-files-o'></i></a>
        </td> 
<td><?=$row['numero_corsa'].' DEL '.$gest_date->data_uk_to_it($row['data']) ?></td>
<?php $autista=$autisti_interni->recupera_da_id($row['id_autista_interno']) ?>
<td> <?=$autista->username?></td>  

<td> 
   <?php 
  $richiedente=$clienti->recupera_da_id($row['id_azienda_richiedente']);
   ?>
       <?php if(!empty($richiedente)){
            echo  $richiedente->ragione_sociale   ;
        }else {
            echo '';
        }

   ?>
   </td>

I Try to use my own function like this :

$columns = array(
array(
    'db'        => 'id_corse_autista_interno',
    'dt'        => 0,
    'formatter' => function( $d, $row ) {
        return "<a href='crea_corse_autista_interno.php?id=".$d."' class='btn btn-primary btn-xs'><i class='fa fa-pencil'></i></a>
           <a href='elimina_corse_autista_interno.php?id=".$d."' class='btn btn-danger btn-xs' onClick=\"return confirm('Sei sicuro di voler eliminare il record?');\"><i class='fa fa-trash-o'></i></a>

           <a href='duplica_corsa.php?id=".$d."' class='btn btn-primary btn-xs'><i class='fa fa-files-o'></i></a>";
    }
),
array( 'db' => 'numero_corsa', 'dt' => 1 ),
array( 'db' => 'data',
       'dt' => 2,
       'formatter' => function( $d, $row ) {

        return date( 'd/m/y', strtotime($d));             }


),
array( 'db' => 'id_autista_interno',  'dt' => 3,

        'formatter' => function( $d, $row ) {

        return $autisti_interni->recupera_da_id($d)->username;             }
 ),
array( 'db' => 'id_azienda_richiedente',   'dt' => 4 )


);

But have error Invalid JSON response ( on return $autisti_interni->recupera_da_id($d)->username; )

How can i use my own function ?

Tanks

Answers

  • allanallan Posts: 63,457Questions: 1Answers: 10,466 Site admin

    What is the server returning if it is not valid JSON? Likely it contains an error message.

    Allan

This discussion has been closed.