Yii 2.0 Use Ajax manage Gridview datatable
[
'class' => 'yii\grid\ActionColumn',
'header'=>'Operate',
'template'=>'{view} {upDown}',
'buttons'=>[
'upDown' => function ($url, $model, $key) {
$label = 'Show';
if ($model->uc_actived == CommonConst::COMSTATUS_YES) {
$label = 'Hide';
}
return Html::a("[$label]", ['#'], ['title'=>$label, 'onclick'=>"
var that = $(this);
$.ajax({
type :'GET',
cache : false,
url : 'set-up',
data : {id: {$model->uc_id}},
success : function(response) {
// change text
if(that.html() == '[Show]'){
that.html('[Hide]')
}else{
that.html('[Show]')
}
}
})
// cancel html link event
return false;
"]);
},
]
],
Leave Comment