|
|
@ -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 |
|
|
|
* @inheritdoc |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected function renderDataCellContent($model, $key, $index) |
|
|
|
protected function renderDataCellContent($model, $key, $index) |
|
|
@ -107,6 +128,7 @@ class ToggleColumn extends DataColumn |
|
|
|
$valueText = $this->offValueText; |
|
|
|
$valueText = $this->offValueText; |
|
|
|
$color = 'red'; |
|
|
|
$color = 'red'; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return Html::a( |
|
|
|
return Html::a( |
|
|
|
'<span class="glyphicon glyphicon-' . $icon . '"></span>', |
|
|
|
'<span class="glyphicon glyphicon-' . $icon . '"></span>', |
|
|
|
$url, |
|
|
|
$url, |
|
|
@ -117,27 +139,6 @@ class ToggleColumn extends DataColumn |
|
|
|
'data-method' => 'post', |
|
|
|
'data-method' => 'post', |
|
|
|
'data-pjax' => '0', |
|
|
|
'data-pjax' => '0', |
|
|
|
] |
|
|
|
] |
|
|
|
) . ( $this->displayValueText ? " {$valueText}" : "" ); |
|
|
|
) . ($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'); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |