2
votes

I'm currently using DataTables 1.10.5 server-side processing feature: http://www.datatables.net/examples/data_sources/server_side.html

Haven't done any major modifications yet, just inserted the column names, etc.

$columns = array(
array( 'db' => 'clinicaId', 'dt' => 0 ),
array( 'db' => 'rotaId',  'dt' => 1 ),
array(
    'db'        => 'delegadoId',
    'dt'        => 2,
    'formatter' => function( $d, $row ) {
        $delegado = new Delegado($d);
        return $delegado->display('name');
    }
));

So, in my sql table, I have 2 columns called cp4 (format: 0000), and cp3 (format: 000) that are part of a postal code.

I want to merge those columns into one, when displaying on a datatable (format: 0000-000). This could be solved quickly, by rewriting my SQL tables. But that would defeat the purpose of having them separated, so I can get the specific location it refers to without having to explode the results.

I haven't found anything specific for my struggle. Already wasted about 2 hours on this, any enlightenment will be much appreciated.

1

1 Answers

0
votes

Try concatenating them:

array( 'db' => '`field1`.`field2`', 'dt' => 'concatenated_fields' ),