Yii2: How to Create Default Column Order in Gridview

Default column order in Gridview can be modified in model file. Open model file and add the following code:

$dataProvider = new ActiveDataProvider([
  'query' => YourClass::find(),
  'sort' => [
    'defaultOrder' => [
        'column_name' => SORT_ASC,

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.