ssp
ssp copied to clipboard
Changing column names
Recently i had issue when i was using renaming columns using AS using joined tables because some tables have same column names.
I was getting error undefined index: novi_naziv
and search on column header and search input was not working.
$columns = array(
array('db' => 'c.naziv AS novi_naziv', 'dt' => 1, 'field' => 'novi_naziv')
);
Using same name in fields was causing that i had same output in 2 columns in datatables, so i needed to use AS to change column name for joined tables, this is example for this scenario, you can see on image below also
$columns = array(
array('db' => 'a.naziv', 'dt' => 1, 'field' => 'naziv'),
array('db' => 'c.naziv', 'dt' => 2, 'field' => 'naziv')
);
FIX for this, at least it works for me
if (strpos($column['db'], 'AS') !== FALSE) {
$column['db'] = explode('AS', $column['db'])[0];
}
those changes was made in those functions in SSP class
function order()
function filter()