Search code examples
phpgridviewyii2dataprovider

yii2 GridView header link remove


In yii2 gridview, I have this code:

echo GridView::widget([
        'dataProvider' => $dataProvider,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn',
                'options' => [
                        'width' => '40',
                    'label' => false,
                    'format' => 'raw',
                ],

            ],

            'title',

            [
                'class' => 'yii\grid\ActionColumn',
                'contentOptions' => [],
                'header'=>'',
                'template' => '{link}',
                'buttons' => [
                    'link' => function ($url,$model,$key) use($url) {
                        return Html::a(Yii::t('app','app.Application job'), $url->url.'?application='.$model->id, ['class' => 'btn btn-application-button']);
                    },
                ],
                'options' => ['width' => '60'],
            ],
        ],
    ]);

in header of table In grid view, text is being generated with some url address....

/career/index?first_step=pagetitle-60&sort=title

Url is broken and unnecessary, but how can I remove it? and to be just text ?

this is code from table:

<table class="table table-striped table-bordered">
  <colgroup>
    <col width="40" format="raw">
      <col width="60"></colgroup>
        <thead>
            <tr>
              <th>#</th>
              <th><a href="/bg/career/index?first_step=%D0%BA%D0%B0%D1%80%D0%B8%D0%B5%D1%80%D0%B8-60&amp;sort=title" data-sort="title">Позиция</a></th>
              <th class="action-column">&nbsp;</th>
            </tr>
         </thead>

.... //this is link that i want to be just text in raw format


Solution

  • Try assign sort = false to your dataProvider .. eg:

     $dataProvider['sort'=>false];
    

    this should disable the sort and the sort requested invoked using the unwanted url