Yii 2.0 GridView Remove Search and Sort Function

When coding with Yii 2.0 framework, GridView is really very powerful, but sometime we need remove Sort and Search functions, the follow code show how to do it.


{ Remove Sort }

Open Models's XXXXSearch.php file, add follow code

        $dataProvider = new ActiveDataProvider([
            'query' => $query,
        // Remove Sort



{ Remove Search and Hide Search Input Row }

Open views/xxxx/index.php file, do the follow change

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
// Remove Search and hide search input row
//         'filterModel' => $searchModel,
        'columns' => [