datatables search not work when field is out of table in database

datatables search not work when field is out of table in database

roytaroyta Posts: 6Questions: 3Answers: 0
edited October 2018 in Free community support

hello i use simple datatables with default settings
and use server processing
and my server side codes is like this

 $table = 'lead';




$primaryKey = 'id';
$colnowid = 2;
// Array of database columns which should be read and sent back to DataTables.
// The `db` parameter represents the column name in the database, while the `dt`
// parameter represents the DataTables column identifier. In this case object
// parameter names

include_once( 'jdf.php' );
include_once( 'config.php' );

$columns = array(

array(
    'db' => 'id',
    'dt' => 'id',
    'formatter' => function ( $d, $row ) {


        if(1 == 1 ){
        return  '<a href="lead-add.php?id='.$d.'">ویرایش</a> ';
        }


    }
),
array(
    'db' => 'type',
    'dt' => 'type',
    'formatter' => function ( $d, $row ) {
        global $colnowid;
        return '<a href="lead-view.php?id='.$colnowid.'">'.$d.'</a>';
    }
),
array(
    'db' => 'cat',
    'dt' => 'cat',
    'formatter' => function ( $d, $row ) {
        return $d;
    }
),
array(
    'db' => 'contact_id',
    'dt' => 'contact_id',
    'formatter' => function ( $d, $row ) {
        if ( !isset( $db ) ) {
            $db = db();
        }
        if($d != ''){

            $c = qselect("select name from contact where id = $d limit 1",$db);
            }
            return $c['name'];
        }else{ return '';}
    }
),
// SQL server connection information
$sql_details = array(
    'user' => $dbuser,
    'pass' => $dbpass,
    'db' => $dbname,
    'host' => 'localhost'
);

require( 'ssp.class.php' );
$db = db();
echo json_encode( SSP::simple( $_POST, $sql_details, $table, $primaryKey, $columns ) );die;

everything work perfectly
my search for type,cat and others work ok
but its do not search for contact name because i get it from another table in database
so any idea how make this work?

Answers

This discussion has been closed.