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; }, ), ), ), );
Be the first person to leave a comment
Please login to leave your comment.