Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing column names #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Changing column names #29

wants to merge 1 commit into from

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