Hi,,
Can anyone clear my doubt?????
As per my requirement I want to concatenate two fields of database and display under the single column of the header. I am using this code:
$header = array(
array('data' => t('Customer_id'), 'field' => 'cust.customer_id'),
array('data' => t('Last Name'), 'field' => 'cust.res_lname'), //here I want to add one more field cust.res_name
);
$result = db_select('customer_details', 'cust')
->extend('TableSort')
->extend('PagerDefault')
->limit(20)
->fields('cust',array('customer_id','res_lname','res_name'))
->orderByHeader($header)
->execute();
$rows = array();
foreach ($result as $row) {
$rows[] = array('data' => (array) $row);
}
$build['tablesort_table'] = array(
'#theme' => 'table',
'#header' => $header,
'#rows' => $rows,
);
$build['rep-tab-end'] = array(
'#markup' => '
'.$output .= theme('pager', array('tags' => array())).'
'
);
Comments
In the future, please wrap
In the future, please wrap your code in <?php ?> tags. It makes it easier for us to read.
Anyways:
I made a few small changes but the overall idea should work.
Actually, I just realized you
Actually, I just realized you may want two DB column values to be shown in one HTML column. In that case, you would do the following:
Note that if you do this, the column will only be sortable on the first value, not the second.