Combining the data from 2 columns into one column for display in table?
Combining the data from 2 columns into one column for display in table?
Is it possible using server side processing to combine 2 values (2 different columns) so they are rendered together in one cell in a table? For instance I'm retrieving 'City' and 'State'. In my rendered table I would like to have it show the City and State together instead of having to have 2 separate columns
Hope that makes sense...
tj
Hope that makes sense...
tj
This discussion has been closed.
Replies
[code]
mData: null,
mRender: function (data, type, row) {
return row.City +', '+ row.State;
}
[/code]
Allan
(assuming php)
[code]
// sql - using ltrim(rtrim(city)) will remove any whitespace in the data as well
$sql = "select city + '/' + state as 'city/state'"
//json
$arr = array();
$arr[0] = $city.'/'.$state;
return json_encode($arr);
[/code]
This will concatenate the 2 fields together. Most SQL engines have similar functionality.