Combine Columns - server_processing.php
Combine Columns - server_processing.php

Hey all,
I'm looking for a way to combine a few columns from my database into a single one.
Adres_Street
Adres_Number
Adres_Bus
Adres_Code
Adres_City
These are 4 different columns, that I want to read from my database. They all work seperate, but I want to get them in one column on my website.
Adres_Street Adres_Number Adres_Bus / Adres_Code Adres_City
The Adres_Bus
part should only show if it's not NULL
I've tried modifying the following part in server_processing.php, but keep getting syntax errors
$columns = array(
array( 'db' => 'Firm', 'dt' => 0 ),
array( 'db' => 'Adres_Street', 'dt' => 1 ), << tried changing this in various ways
array( 'db' => 'Phone', 'dt' => 2 ),
array( 'db' => 'Website', 'dt' => 3 ),
array( 'db' => 'Contact', 'dt' => 4, ),
array( 'db' => 'Status', 'dt' => 5, )
);
Ideal solution for me would be to be able to alter it and make a single $variable that I can insert into the $column array.
For instance:
$CombinedColumn = $Adres_Street . " " . $Adres_Number . " " . $Adres_Bus . " / " . $Adres_Code . " " . $Adres_City
Hope someone can help me out!
This question has an accepted answers - jump to answer
Answers
Found this SO post... but I keep getting errors.
My current code is
I would suggest you use a data renderer to combine multiple SQL columns into a single column.
Allan
How would I implement this in my current page?
Snippet from the table part:
server_processing.php
There's an example here:
https://datatables.net/examples/advanced_init/column_render.html
Perfect! Thanks @tangerine
Any chance on doing this server side too?
Yes, you should be able to do this with server-side processing as well.
Allan
Although https://datatables.net/examples/advanced_init/column_render.html does render correctly, the problem comes in when you want to search/filter while using server side processing.
What worked for me when using server_processing.php was: