Tôi đang sử dụng Pjax với GridView và tôi muốn tất cả các nút hành động của tôi làm ajax. Theo mặc định, họ không, vì vậy tôi googled và tìm cách để loại bỏ dữ liệu-pjax = 0. Nhưng vẫn còn, không có yêu cầu ajax, tất cả chúng đều là yêu cầu thường xuyên.Yii 2: Pjax + Gridview xóa không gửi yêu cầu ajax
Rất nhiều người gặp sự cố này và tôi cũng không thể tìm được giải pháp.
Tôi đã theo:
Mã của tôi:
<?php Pjax::begin(['id' => 'employee-timesheet-grid-id', 'timeout' => false, 'enablePushState' => false, 'clientOptions' => ['method' => 'POST']]) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'label' => 'Employee',
'value' => function ($model) {
return $model->employeePayRate->employeeName;
},
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{view} {delete}',
'buttons' => [
'delete' => function ($url , $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url,
['data-confirm' => 'Are you sure you want to delete this item?', 'data-method' =>'POST']);
}
],
'urlCreator' => function ($action, $model, $key, $index) {
if ($action === 'view') {
$url = Url::to(['employee-time-sheet/view', 'id' => $model->id]);
return $url;
} else if ($action === 'delete') {
$url = Url::to(['employee-time-sheet/delete', 'id' => $model->id]);
return $url;
}
}
],
],
]); ?>
<?php Pjax::end(); ?>
Có ai tìm thấy giải pháp cho vấn đề này chưa?
tôi đã làm giải pháp –