Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.

Disable sorting on specific columns

benjaminu edited this page Dec 5, 2012 · 2 revisions

By default the sorting functionality is enabled on all columns, to get it working you just need to activate it from your configuration method like this :
    return $this->get('datatable')
        ->setEntity($this->_entity_name, 'entity')
        ->setEntity('XXXMyBundle:Entity', 'x') // replace 'XXXMyBundle:Entity' by your entity
        ->setFields(
            array(
                'Name'         => 'x.name', // Declaration for fields: 
                'Address'      => 'x.address', // 'label' => 'alias.field_attribute_for_dql'
                'Group'        => 'x.group',
                'Team'         => 'x.team',
                '_identifier_' => 'x.id' // you have to put the identifier field without label. Do not replace the '_identifier_'
            )                         
        )
        ->setColumnSortStatus(array(1 => false, 3 => false)); // Disable sorting on 'address', and 'team' columns.