select all in gridview

Hi guys, I need help with this problem

I have a gridview with button for every row like on the picture. I want to have my own button for select all rows which are displayed right now. How can i do that ? Button should be at the place, where is a red circle, on the picture

This is my gridview


  

<?= GridView::widget([

        'dataProvider' => $dataProvider,

        'filterModel' => $searchModel,

        'summary'=>'',

        'rowOptions'=>function($model)

            {

                if($model->add == 1) {

                    return ['class'=>'success'];

                }

            },

        'columns' => [

            ['class' => 'yii\grid\SerialColumn'],

            [

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

                'template'=>'{add}',

                'buttons'=>[

                    'add' => function ($url, $model) {

                            return render_button($model->add ,$url);

                    }

                ]

            ],

            'shop',

            'category',

            'product:ntext',

            'prise',

            'shop_category:ntext',

            [

                'attribute' => 'img',

                'format' => 'html',

                'label' => 'Image',

                'value' => function ($data) {

                    return Html::img( $data['img_url'], ['width' => '70px']);

                },

            ],

            [

                'label'=>'shop',

                'format' => 'raw',

                'value'=>function ($data) {

                    return Html::a('buy',$data->url);

                },

            ],

             'delivery_date',

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

        ],

    ]); ?>



thanks for any help

From docs: The columns of the grid table are configured in terms of yii\grid\Column classes, which are configured via $columns.

And each column have a "header" property. So you can set anything you want in the header.

thanks, I did not notice that. But now, I don’t know how can I use a function in header, is that even possible?

No, you cannot use an anonimous function. You must provide the html code.

I used button in header and action on click in button :) it’s working now