|
|
|
@ -87,6 +87,27 @@ class ToggleColumn extends DataColumn
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Registers the ajax JS |
|
|
|
|
*/ |
|
|
|
|
public function registerJs() |
|
|
|
|
{ |
|
|
|
|
if (Yii::$app->request->isAjax) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$js = <<<'JS' |
|
|
|
|
$(document.body).on("click", "a.toggle-column", function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
$.post($(this).attr("href"), function(data) { |
|
|
|
|
var pjaxId = $(e.target).closest("[data-pjax-container]").attr("id"); |
|
|
|
|
$.pjax.reload({container:"#" + pjaxId}); |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
JS; |
|
|
|
|
$this->grid->view->registerJs($js, View::POS_READY, 'zx-toggle-column'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @inheritdoc |
|
|
|
|
*/ |
|
|
|
|
protected function renderDataCellContent($model, $key, $index) |
|
|
|
@ -107,6 +128,7 @@ class ToggleColumn extends DataColumn
|
|
|
|
|
$valueText = $this->offValueText; |
|
|
|
|
$color = 'red'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Html::a( |
|
|
|
|
'<span class="glyphicon glyphicon-' . $icon . '"></span>', |
|
|
|
|
$url, |
|
|
|
@ -117,27 +139,6 @@ class ToggleColumn extends DataColumn
|
|
|
|
|
'data-method' => 'post', |
|
|
|
|
'data-pjax' => '0', |
|
|
|
|
] |
|
|
|
|
) . ( $this->displayValueText ? " {$valueText}" : "" ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Registers the ajax JS |
|
|
|
|
*/ |
|
|
|
|
public function registerJs() |
|
|
|
|
{ |
|
|
|
|
if(Yii::$app->request->isAjax) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$js = <<<'JS' |
|
|
|
|
$(document.body).on("click", "a.toggle-column", function(e) { |
|
|
|
|
e.preventDefault(); |
|
|
|
|
$.post($(this).attr("href"), function(data) { |
|
|
|
|
var pjaxId = $(e.target).closest("[data-pjax-container]").attr("id"); |
|
|
|
|
$.pjax.reload({container:"#" + pjaxId}); |
|
|
|
|
}); |
|
|
|
|
return false; |
|
|
|
|
}); |
|
|
|
|
JS; |
|
|
|
|
$this->grid->view->registerJs($js, View::POS_READY, 'zx-toggle-column'); |
|
|
|
|
) . ($this->displayValueText ? " {$valueText}" : ''); |
|
|
|
|
} |
|
|
|
|
} |