Closed dudunegrinhu closed 9 years ago
Hope you have read the default yii guide. You may once want to do that.
This is addressed in yii\grid\CheckboxColumn... you need to write your javascript accordingly.
The selected rows may be obtained by calling the following JavaScript code:
var keys = $('#grid').yiiGridView('getSelectedRows');
// keys is an array consisting of the keys associated with the selected rows
This is also highlighted in the Krajee Grid Documentation for Checkbox Column.
@kartik-v I already tried that but it gives me an error:
TypeError: $(...).yiiGridView is not a function
The error means you are using a wrong identifier for your grid. The HTML ID attribute must pertain to your gridview container.
For Dynagrid you set gridview widget properties via gridOptions
- hence you can access the grid ID attribute through gridOptions['options']['id']
. You may need to set a value for this and access. For example:
// widget php script
echo Dynagrid::widget([
'options' => ['id' => 'dynagrid'], // this is dynagrid identifier
'gridOptions' => ['options' => ['id' => 'grid']], // this is gridview identifier
// add other settings required by DYNAGRID
]);
Then access the same via javascript.
// js script
var keys = $('#grid').yiiGridView('getSelectedRows');
// keys is an array consisting of the keys associated with the selected rows
@kartik-v if I fix my javascript, it was because was inside the domready but now when I get the selected rows I get this error:
TypeError: data is undefined if (data.selectionColumn) {
Sorry @kartik-v it worked now, it was a conflict name on both id's. Thanks for the clarification. I would like to make a donation to you because I'm using a lot of your components and if you have the time I would like to hire you as a consultant.
I get this error : Setting unknown property: kartik\grid\GridView::gridOptions
thanks a lot it's working fine but if you may how I get the full row data using the key?
Kartik,
Sorry to open an issue for this but I'm trying for almost month already and with no success. I need to get the selected rows (checkbox) so I can export or do whatever I can do with all the selected rows.
Can you help me please?