Skip to content

Ordering doesn't work for mDataSupport = true #200

Open
@stevenmyhre

Description

@stevenmyhre

If you do something like:

Datatables::of($this->repo->getList()->select($this->repo->getListColumns()))->make(true);

The ordering is off (indexed by the server side columns rather than client side columns)
Here's the fix I applied to get it working - this may or may not have broken other ways of sorting (without mData for example)

protected function ordering()
    {
        if (array_key_exists('order', $this->input) && count($this->input['order']) > 0) {
            $columns = $this->cleanColumns($this->aliased_ordered_columns);

            for ($i = 0, $c = count($this->input['order']); $i < $c; $i++) {
                $order_col = (int)$this->input['order'][$i]['column'];
                if (isset($this->input['columns'][$order_col])) {
                    if ($this->input['columns'][$order_col]['orderable'] == "true") {
                        $this->query->orderBy($this->input['columns'][$order_col]['data'], $this->input['order'][$i]['dir']);
                    }
                }
            }

        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions