how to disable sorting on GridView with GridView attributes

Good Morning everyone,

I am using GridView for exporting excel and pdf in view form, but i not able to disable sorting on GridView.

anyone can help me to resolve this issue. :rolleyes:

my GridView is

<?= GridView::widget([

        'dataProvider' => $model,

	'layout' => '{items}',

	'id' => 'course-grid',

        'columns' => [


		'class' => 'yii\grid\SerialColumn',

		'header' => 'SI No.',



		'attribute' => 'course_name',	



		'attribute' => 'course_code',



    ]); ?>

Check this one

Hopefully it helps.

This solution works in GridView but i having two view page one for "index.php" and second one for "ExportPdfExcel.php".

so, now i want to disable sorting in "ExportPdfExcel.php" view page but not in "index.php".

go to your action in your controller then try this:

return $this->render('viewfilename', [

   'dataProvider' => new ActiveDataProvider([

    'query' => YourQuery,

    'sort' => false,

    'pagination' => [

      'pageSize' => anyNumber,




Hopefully it helps.

can i use


for disable sorting in GridView