Skip to content

Instantly share code, notes, and snippets.

@mdeweerd
Last active July 3, 2020 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdeweerd/911b254b5c2d7ca17db7 to your computer and use it in GitHub Desktop.
Save mdeweerd/911b254b5c2d7ca17db7 to your computer and use it in GitHub Desktop.
<?php
$isAjaxUpdate=Yii::app()->request->isAjaxRequest;
if(!$isAjaxUpdate||Yii::app()->request->getParam('ajax')==='mygridid')
$this->widget('zii.widgets.grid.CGridView',
array(
'id'=>'mygridid',
'dataProvider' => new CArrayDataProvider(
array(
array(
'id'=>1,
'name' => 'Doe'
)
)),
'filter'=>1,
'afterAjaxUpdate' => "function(id,data){alert('afterAjaxUpdate');}",
'selectionChanged'=>"function (id) {alert('selectionChanged');}",
'columns' => array(
array(
'filter'=>
$this->widget("zii.widgets.jui.CJuiButton",
array(
"name" => "dummy",
"buttonType" => "button",
"caption" => "update me",
"onclick" => "function(){window.setTimeout(function(){alert('clicked');},2);jQuery('#mygridid').yiiGridView('update')}",
), true)
,
'name' => 'name',
'type'=>'raw',
)
)
));
if(!$isAjaxUpdate||Yii::app()->request->getParam('ajax')==='mygridid2')
$this->widget('zii.widgets.grid.CGridView',
array(
'id'=>'mygridid2',
'dataProvider' => new CArrayDataProvider(
array(
array(
'id'=>1,
'name' => 'Doe'
)
)),
'filter'=>1,
'afterAjaxUpdate' => "function(id,data){jQuery('body').append(jQuery(data).filter('script:not(\"[src]\")'));alert('afterAjaxUpdate');}",
'selectionChanged'=>"function (id) {alert('selectionChanged');}",
'columns' => array(
array(
'filter'=>
$this->widget("zii.widgets.jui.CJuiButton",
array(
"name" => "dummy2",
"buttonType" => "button",
"caption" => "update me",
"onclick" => "function(){window.setTimeout(function(){alert('clicked');},2);jQuery('#mygridid2').yiiGridView('update')}",
), true)
,
'name' => 'name',
'type'=>'raw',
)
)
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment