Yii 1.1: eajaxlinkcolumn

CGridView column type that that renders an AJAX Link - CHtml::ajaxLink()

CGridView column type that that renders a CHtml::ajaxLink(), it is able to evaluate the ajax options as PHP much the same way the CLinkColumn can evaluate a url or label.

It extends CLinkColumn, so anything it does, this can do.


Yii 1.1


Uses the same syntax as CLinkColumn except you need to include the AJAX options:

Where the EAjaxLinkColumn.php file is located in the extensions directory.

//this is not a full CGridView declaration
$this->widget('zii.widgets.grid.CGridView', array(
  'columns' => array(
    array('class' => 'ext.EAjaxLinkColumn',
      'label' => 'Link Text',
      'url' => Yii::app()->createUrl('blah/blah'),
      //linkAjaxOptions and linkAjaxOptionsExpression are merged together, so only put the ones
      //that actually need to be evaluated in the latter
      'linkAjaxOptions' => array(
         'type' => 'POST',
         'dataType' => 'json',
      //In this expression, the variable $row the row number (zero-based); 
      //$data the data model for the row; and $this the column object.
      'linkAjaxOptionsExpression' => array(
         'data' => array(
           'id' => '$data->id', //note that $data->id is an expression so must be quoted
           //with php 5.3 or higher you can use an anonymous closure
           'name' => function($data){
                       return $data->firstName . $data->lastName;

Total 2 comments

#17524 report it
Luke Jurgs at 2014/06/27 10:46pm
AJAX options


You could use the linkAjaxOptions or linkAjaxOptionsExpression property and set the success property. For example:

'linkAjaxOptions' => array(
 'type' => 'POST',
 'dataType' => 'json',
 'success' => "js: function() { alert('success!'); }",

Happy coding!

#17513 report it
sefburhan at 2014/06/26 01:52am
success message

thanks for such a valuable extension, it saved my too much time, but can you guided me how to show message like on success , etc.?

Leave a comment

Please to leave your comment.

Create extension