No buttons in action column in gridview

Hi

I am using PHPManager for access control in Yii2 advanced template. I have set up authmanager as follows:




        'authManager'=>[

            'class' => 'yii\rbac\PhpManager',

        ],




In my controller, I have set up rules as follows:




        return [

            'access'=>[

                'class' => AccessControl::className(),

                'only' => ['view', 'index', 'create', 'update', 'delete'],

                'rules' => [

                    [

                        //'actions' => ['view', 'index', 'create', 'update', 'delete'],

                        'allow' => true,

                        'roles' => ['@'],

                    ],

                ],

            ],

        ];




I have generated crud functions with gii and the code for gridview is as follows:




    <?php echo GridView::widget([

        'dataProvider' => $dataProvider,

        'columns' => [

            [

                //'attribute'=>'id',

                'class' => 'yii\grid\CheckboxColumn'

            ],


            'Job_Name',

            [

                'attribute'=>'Cat_Id',

                //'header'=>'Job Category',

                'value'=>function($model)

                {

                    return Category::getCategoryName($model->Cat_Id);

                }

            ],

            'Employer',

            [

                'attribute'=>'IsDisclosed',

                'value'=>function($model)

                {

                    if($model->IsDisclosed)

                        return 'Yes';

                    else

                        return 'No';

                }

            ],

            // 'IsShow',

            // 'CanAccess',

            // 'Salary',

            // 'SalaryPer',

            // 'Location',

            // 'Date_Posted',

            // 'Apply_Before',

            // 'Specific_Attributes:ntext',

            // 'Responsibilities:ntext',

            // 'Contact_Person',

            // 'Job_Ref',

            // 'Position_Type',

            // 'Experience:ntext',

            // 'Education:ntext',


            [

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

            ],

        ],

    ]); ?>



This code was supposed to show links/buttons/icons in the action column for view, update and delete but I don’t see any at all.

Did I do something wrong with the configuration? Or did I miss something anywhere?

Can anybody please help me?

Thanks in advance.

Code looks fine to me.

Is there any records in the grid because if there is not then it wont show buttons. I know its obvious but might be so obvious you might have missed it.

I take it you also put …




use yii\grid\GridView;



At the top of your view?

Can you check if its generated the html for the button column or buttons. Might just be the icons that are missing?

Yes. I have loaded yii/grid/Gridview. The html code produced for the action column is as follows:




<div class="dropdown"><button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">Actions <span class="caret"></span></button><ul class="dropdown-menu pull-right" role="menu">  </ul></div>



The links for actions should be inslide ul tag, but there is nothing there.

Why is it loading a dropdown list? The code should look nothing like that. Should be more like this …




<td>


    <a data-pjax="0" title="Update" href="/projects/yii2-projects/yii-sign-up-sign-in-system/web/index.php?r=user%2Fupdate&id=1">

        <span class="glyphicon glyphicon-pencil"></span>

    </a>

    <a data-pjax="0" data-method="post" data-confirm="Are you sure you want to delete this item?" title="Delete" href="/projects/yii2-projects/yii-sign-up-sign-in-system/web/index.php?r=user%2Fdelete&id=1">


    <span class="glyphicon glyphicon-trash"></span>

</a>

</td>



That is my concern as well. I am using the code generated by gii.

Hi, I found an issue with using Katrik Icons that will disable glyicons and not show any action buttons.

My solution is to use another app\components\ActionColumn and change the icon to the icon::show


use Yii;
use yii\helpers\Html;
use yii\helpers\Url;
use kartik\icons\Icon;


protected function initDefaultButtons()
    {
        #change the name of the icon
        $this->initDefaultButton('view', 'eye');
        $this->initDefaultButton('update', 'edit');
        $this->initDefaultButton('delete', 'trash-alt', [
            'data-confirm' => Yii::t('yii', 'Are you sure you want to delete this item?'),
            'data-method' => 'post',
        ]);
    }


#line184    
#$icon = Html::tag('span', '', ['class' => "glyphicon glyphicon-$iconName"]);
$icon = Icon::show($iconName);

This will replace that column with the new icons.