cnizzardini / cakephp-datatable

CakePHP Component for interoperability between CakePHP 2.x and jQuery DataTables plugin.
62 stars 49 forks source link

Multi column sorting #28

Open walliby opened 9 years ago

walliby commented 9 years ago

Multi column sorting does not seem to be working. Looks like maybe this wasnt coded yet as I can only find reference to iSortCol_0 in the component. Can you confirm I'm not just missing something on the js end? Thanks

cnizzardini commented 9 years ago

This has not been implemented and frankly I have not been developing on this much. It needs to be ported to Cake3 since that is where my focus is now and the cake2 version needs to be forked by someone who will take over development.

On Mon, Mar 2, 2015 at 1:41 PM, Joshua Wallace notifications@github.com wrote:

Multi column sorting does not seem to be working. Looks like maybe this wasnt coded yet as I can only find reference to iSortCol_0 in the component. Can you confirm I'm not just missing something on the js end? Thanks

— Reply to this email directly or view it on GitHub https://github.com/cnizzdotcom/cakephp-datatable/issues/28.

walliby commented 9 years ago

Gotcha. I don't use git at work though we may switch in the future. For now, here's the code I used for multi column ordering...

    $sorting_cols = $this->controller->request->query['iSortingCols'];

    for($col = 0; $col < $sorting_cols; $col++) {

        if( !empty($fields) && isset($this->controller->request->query['iSortCol_' . $col]) ){
            $direction = $this->controller->request->query['sSortDir_' . $col] === 'asc' ? 'asc' : 'desc';
            $orderBy .= $fields[ $this->controller->request->query['iSortCol_'  . $col] ].' '.$direction.', ';
        }

    }
spkljl commented 9 years ago

Hi walliby,

I tried the code but it seems not work in my app.