Skip to content

extraColumns and serverSide does not get along well #57

@adantart

Description

@adantart

Hi!
Amazing package ;-)
I've tried to activate the serverSide but the datatables action ajax call gives me an error:

Unknown column 'columnNameSpecial' in 'order clause' The SQL being executed was: SELECT * FROM client ORDER BY columnNameSpecial LIMIT 10"

being "columnNameSpecial" one of the "extraColumns" I have declared in the widget.

When you use extraColumns to put enhanced information, you need to put the name of the model function in the "data" attribute of each column. I mean, for example:

            'columns' => [
                    [
                        'data' => 'columnNameSpecial',
                        'title' => 'Name',                    
                        'render' => new JsExpression('function render(data, type, row, meta ){
                            return row.columnNameSpecial;
                        }'),
                    ],
                    ....

having in the model for example:

function getColumnNameSpecial() {
   return $this->name . " " . $this->lastname;
}

But in the other hand, the applyOrder and applyFilter of 'datatables' array in actions() needs the $column["data"] to be a REAL attribute of the model, because it will construct with that name, the applyFilters and orderBy of the ActiveRecord. That's the reason I have the "sql error" of the beginning.

Any ideas ? ;-)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions