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

  1. Requirements
  2. Usage

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;
9 0
1 127 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: User Interface
Developed by: Luke Jurgs
Created on: Jan 10, 2012
Last updated: 9 years ago


show all

Related Extensions