You should not put scripts in the formatter.
Remove:
$js = <<<EOD
console.log("test");
EOD;
$cs = Yii::app()->getClientScript();
$cs->registerScript("testjs", $js);
Configure your grid view:
<?php $this->widget('zii.widgets.grid.CGridView', array(
//.. other options
// ADD THIS
'afterAjaxUpdate' => 'function() { afterAjaxUpdate(); }',
Add to <head>
of /layouts/main.php:
<script src="<?= Yii::app()->getBaseUrl(true); ?>/js/myCustomJS.js"></script>
Create new JS file at /js/myCustomJS.js:
function afterAjaxUpdate() {
// do your formatting here
}