I wants to know if there is any inbuilt option in yii2 gridview checkbox column to select/deselect all rows at once..
For example if i have 500 records in a gridview and i am displaying 100 records at once than i can only select 100 records at once and do any bulk action.
I want user to be able to select all 500 records at once and do any bulk action with those record at once.. hope you all get my question
I made a suggestion to yii framework owners on github
and they have confirmed that they will do this enhancement soon enough and put this issue in enhancement section, so hoping that they will include it soon enough but until then guide me to achieve this in any alternate way
Thank you
Yes, You can use CheckBoxColumn. Just add the following lines into your GridView
's columns array:
[
'class' => 'yii\grid\CheckboxColumn',
'name' => 'id'
],
As Yii2's
Official document:
CheckboxColumn
displays a column ofcheckboxes
in a grid view. To add aCheckboxColumn
to theyii\grid\GridView
, add it to the columns configuration as follows:
'columns' => [
// ...
[
'class' => 'yii\grid\CheckboxColumn',
// you may configure additional properties here
],
]
Users may click on the
checkboxes
to select rows of the grid. The selected rows may be obtained by calling the followingJavaScript
code:
var keys = $('#grid').yiiGridView('getSelectedRows');
// keys is an array consisting of the keys associated with the selected rows
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