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

[BUG]: change getColumns to be able to work with Relations with underscore DT #938

Open
romanstingler opened this issue Jan 15, 2021 · 0 comments
Labels

Comments

@romanstingler
Copy link

romanstingler commented Jan 15, 2021

due to bugs

yajra/laravel-datatables#2324
yajra/laravel-datatables-html#123

due to code in
HasColumns.php

...
        foreach ($columns as $key => $value) {
            if (!is_a($value, Column::class)) {
                if (is_array($value)) {
                    $attributes = array_merge(
                        [
                            'name' => $value['name'] ?? $value['data'] ?? $key,
                            'data' => $value['data'] ?? $key,
                        ],
                        $this->setTitle($key, $value)
                    );
                } 
...

the default template doesn't work

protected function getColumns()
{
        return [
           'jobState.name'
        ];
}

the working solution is to change the returned array and the working function looks like

    protected function getColumns()
    {
        return [
            'jobState.name' => ['data' => 'job_state.name', 'name' => 'jobState.name'],
        ];
    }

so the key is used for the title due to this line
$this->setTitle($key, $value)

@ShaileshInfyom ShaileshInfyom changed the title ! change getColumns to be able to work with Relations with underscore DT [BUG] ! change getColumns to be able to work with Relations with underscore DT Jan 28, 2022
@ShaileshInfyom ShaileshInfyom changed the title [BUG] ! change getColumns to be able to work with Relations with underscore DT [BUG]: change getColumns to be able to work with Relations with underscore DT Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants