Обработка выделения объектов в таблице: <script type="text/javascript"> $(document).ready(function(){ $("input[type=checkbox]").click(function(){ var keys = $('#usergrid').yiiGridView('getSelectedRows'); alert(keys); }); }); </script> <div class="user-index"> <h1><?= Html::encode($this->title) ?></h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php Pjax::begin(); ?> <?= GridView::widget([ 'id'=>'usergrid', 'dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [ ['class' => 'yii\grid\SerialColumn'], [ 'class' => 'yii\grid\CheckboxColumn', 'checkboxOptions' => function ($model, $key, $index, $column) { return ['value' => $model->user_id]; } ], 'user_id', 'user_login', 'user_pass', 'user_name', 'user_active', ['class' => 'yii\grid\ActionColumn'], ], ]); ?> <?php Pjax::end(); ?> </div>
Yii Справочник v0.05 © 2007-2024 Igor Salnikov aka SunDoctor