searchable hyperlink from GridView

Hello,

I have two tables which are linked: Campaign (child) and Company (parent).

Using the excellent description from the link below, I have managed to create a fully searchable, sortable column for company.name in the campaign GridView table:

http://www.yiiframework.com/wiki/621/filter-sort-by-calculated-related-fields-in-gridview-yii-2-0/

What I now want to do is turn the company name into a hyperlink which will take the user to the company/view page so that if the user wants to see more detail about the company, they simply click the company name and they are taken to the company details page.

The only solution I have seen is to add this to the GridView:

     [


            'label' => 'Company',


            'format' => 'raw',


            'value'=>function ($data) {


                return Html::a($data['companyName'], ['company/index']);


            },


        ],

The problem is that this column is not searchable nor sortable.

How can I add a hyperlink to the campaign method so that the column is searchable, sortable and provides a hyperlink?

Many thanks

Something like the following should work:




    [

         'label' => 'Company',

         'attribute' => 'companyName',

         'format' => 'raw',

         'value'=>function ($data) {

              return Html::a($data['companyName'], ['company/index', 'id' => $data['company_id']]);

         },

    ],



Fantastic! It worked out the box.

Thanks so much for your help!