如何以表格形式获取ID选定的项目

时间:2019-01-21 04:18:20

标签: php yii2 kartik-v

我使用Tabular Form kartik。我的表格形式有SwitchInput项目。目前,我可以获取有关此元素的状态:false或true。如何获取发生事件的ID项目?还是将我的ID设置为SwitchInput? $ dataProvider =数组数据提供程序。

<?= TabularForm::widget([
'dataProvider' => $dataProvider,
'formName' => 'form',
'actionColumn' => false,
'checkboxColumn' => false,
'attributes' => [
    'id' => [
        'label' => 'ID',
        'type' => TabularForm::INPUT_STATIC,
    ],
    'sent' => [
        'label' => 'Отправлено',
        'type' => TabularForm::INPUT_WIDGET,
        'columnOptions' => ['vAlign' => GridView::ALIGN_MIDDLE],
        'widgetClass'=> \kartik\widgets\SwitchInput::classname(),
        'options' => [
            'pluginOptions' => [
                'onText'=>'Да',
                'offText'=>'Нет',
                'onColor' => 'success',
                'offColor' => 'danger',
                'size' => 'small'
            ],
            'pluginEvents' => [
                'switchChange.bootstrapSwitch' => 'function(event, state) {
                  $.ajax({
                      method: "POST", 
                      url: "'.Url::to(['/site/check']).'",
                      data: { status: state}
                 }) 
                }'
            ],
        ],
    ],
],
'gridSettings' => [
    //'floatHeader'=>true,
    'panel' => [
        'heading' => 'Таблица',
        'after' => false,
        'before' => false,
    ],
],]); ?>

0 个答案:

没有答案