amit5992
(Gupta5992amit)
1
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. 
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',
],
],
]); ?>
CodeGeek
(Mk K Greek)
2
Check this one http://stackoverflow.com/questions/27463817/how-to-enable-and-disable-sort-in-yii2-gridview
Hopefully it helps.
amit5992
(Gupta5992amit)
3
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".
CodeGeek
(Mk K Greek)
4
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.
amit5992
(Gupta5992amit)
5
can i use
setsort()
for disable sorting in GridView