laravel4-datatables-package icon indicating copy to clipboard operation
laravel4-datatables-package copied to clipboard

Ordering doesn't work for mDataSupport = true

Open stevenmyhre opened this issue 10 years ago • 0 comments

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

        }
    }

stevenmyhre avatar Feb 23 '15 22:02 stevenmyhre