tigrang / cakephp-datatable

JQuery DataTable plugin server-side processing component for CakePHP
47 stars 29 forks source link

Order/Sort column on server side. #40

Closed kamilosinski closed 10 years ago

kamilosinski commented 10 years ago

Hi, I want to show Datatable with sorted data eg. 'Model.example DESC'. Should I use Cake's 'ORDER' in DataTable->settings (that doesn't work) or try 'aaSorting' from jquery Datatabels? "aaSorting":{"4":"desc"} also doesn't work.

Regards, Kamil

tigrang commented 10 years ago

That's not the format that aaSorting expects.

Example: "aaSorting": [[ 4, "desc" ]],

kamilosinski commented 10 years ago

Yeah, I've found that in datatables docs, but I have problem with using it in $this->DataTable->render. When I use 'aaSorting' => array(4, 'desc') it results with 'TypeError: k is undefined' in FireBug console.

Regards, Kamil

tigrang commented 10 years ago

What you've done is "aaSorting": [ 4, "desc" ], with 'aaSorting' => array(4, 'desc'). aaSorting is an array of arrays. You need to wrap array(4, 'desc') in another array.

'aaSorting' => array(array(4, 'desc'))

kamilosinski commented 10 years ago

It works! Thank You very much for Your help.

Regards, Kamil