dudapiotr / ZfTable

*Not supported*ZfTable 3.1. Awesome ZF2 table / grid (and much much more) generator with huge possibilities of decorating and conditioning. Integrated with DataTables, Doctrine 2, Bootstrap 2.0 and 3.0.
http://dudapiotrek.laohost.net/
MIT License
75 stars 59 forks source link

Default columns order doesn't work #72

Closed Romano83 closed 9 years ago

Romano83 commented 9 years ago

I try to implement default order to my columns but it doesn't seems to work. I add this in headers' declaration:

protected $headers = array(
            'idservice' => array('title' => 'Nb') ,
            'name' => array('title' => 'Name', 'order' => 'desc'),
            'category' => array('title' => 'Category'),
            'description' => array('title' => 'Description'),
            'providers' => array('title' => 'Provider', 'sortable' => false, "width" => '250'),
            'price' => array('title' => 'Price'),
            'discount' => array('title' => 'Discount'),
            'thumb' => array('title' => ' ', 'sortable' => false),
            'delete' => array('title' => ' ', 'sortable' => false),
    );

I tried to replace 'desc' by 'asc', true or false with no success...

Columns are always order by ID, not by name. Any idea to fix this issue ?

W33k3nd commented 9 years ago

And if you try to order your table, already in your sql statement?

ionutfechete commented 9 years ago

@Romano83 In the initFilters($query) method do something like $query->order(['column_from_header' => 'DESC']);

Romano83 commented 9 years ago

@IonutPerfectWeb Thanks for your reply. It's work fine !