我想在ajax成功函数中刷新kartik gridview,以便我可以看到我在成功更新后所做的更改,但我不知道如何在kartik gridview中调用刷新函数以反映更新。
$.ajax({
type: 'POST',
url:'',
dataType: 'html',
data: {key:keys},
success: function(data){
$.pjax.reload({container:'#pjax_id'});
},
});
以下是Kartik Gridview
echo GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => $gridColumns,
'containerOptions'=>['style'=>'overflow: auto'],
'headerRowOptions'=>['class'=>'kartik-sheet-style'],
'filterRowOptions'=>['class'=>'kartik-sheet-style'],
'id' =>'dempcc_grid_id',
**'pjax'=>true, // pjax is set to always true for this demo
'pjaxSettings' =>[
'neverTimeout'=>true,
'options'=>[
'id'=>'pjax_id',
]
],**
'toolbar'=> [
['content'=>
Html::a('<i class="glyphicon glyphicon-repeat"></i> Refresh', [''], ['data-pjax'=>1, 'class'=>'btn btn-default', 'title'=>'Reset Grid','id'=>'refresh'])
],
'{export}',
'{toggleData}',
],
'panel'=>[
'type'=>GridView::TYPE_PRIMARY,
'heading'=>'REMITTANCE - DEMPCC',
],
'persistResize'=>false,
]);
答案 0 :(得分:0)
<?php \yii\widgets\Pjax::begin(); ?>
<?= GridView::widget([
// ... configuration here
]);
<?php \yii\widgets\Pjax::end(); ?>
并更新: $ .pjax.reload({容器: '#idofyourpjaxwidget'});
http://www.yiiframework.com/wiki/655/how-to-use-gridview-with-ajax/