I am very new to yii2. I have created a gridview using CRUD Generator. I want to make the gridview's rows to be clickable like when we click on view. It should navigate to the view page for that row.
My gridview code is as follows:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'Task_ID',
'Task_Title',
'Description',
//'employee.employee_name',
//'Assign_task_to',
'start_date',
'due_date',
'priotiy_level',
// 'complexity_level',
// 'upload_documents',
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
below code added Task_Title
as clickable:
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute'=>'Task_Title',
'format'=>'raw',
'value' => function($data)
{
return
Html::a($data->Task_Title, ['task/view','id'=>2], ['title' => 'View','class'=>'no-pjax']);
}
],
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With