Skip to content

Conversation

@mlukac89
Copy link

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')
);

error

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()

Fixes when you want to rename column names like

$columns = array('db' => 'a.column AS 'some_name', 'dt' => 3, 'field' => 'some_name')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant