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

Ordering doesn't work for mDataSupport = true #200

Open
stevenmyhre opened this issue Feb 23, 2015 · 0 comments
Open

Ordering doesn't work for mDataSupport = true #200

stevenmyhre opened this issue Feb 23, 2015 · 0 comments
Labels

Comments

@stevenmyhre
Copy link

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

        }
    }
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