我需要在yii2 gridview上使用datepicker。所以我使用了jui扩展。它工作正常。但是当我去pjax时,每当我更改datepicker值时它会自动重新加载页面。如果有人知道这件事,请指导我。
这是我的代码:
<?php
use yii\helpers\Url;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use yii\jui\DatePicker;
use yii\helpers\ArrayHelper;
Pjax::begin();
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'attribute' => 'td_created_datetime',
'filter' => \yii\jui\DatePicker::widget([
'model' => $searchModel,
'attribute' => 'td_created_datetime',
'language' => 'en',
'dateFormat' => 'yyyy-MM-dd',
'clientEvents' => [
'change' => "function(e){
alert('occured');
e.preventDefault();
}"
],
]),
],
],
]);
Pjax::end();
?>