Sonata admin bundle order

后端 未结 2 1257
忘了有多久
忘了有多久 2020-12-17 15:21

How to change default entity order in SonataAdminBundle for list action?


answer :) add this to your admin class

protected $datagri         


        
2条回答
  •  半阙折子戏
    2020-12-17 16:04

    You can add another sort order or set a default one via the constructor like this:

    public function __construct($code, $class, $baseControllerName)
    {
        parent::__construct($code, $class, $baseControllerName);
    
        if (!$this->hasRequest()) {
            $this->datagridValues = array(
                '_page'       => 1,
                '_sort_order' => 'ASC',      // sort direction
                '_sort_by'    => 'artist_id' // field name
            );
        }
    }
    

提交回复
热议问题