0

I am updating a column(NAME) in my grid table using $grid->updateColumn command. But i need to update that column based on a condition.

This is the command i am using now, to convert the 'NAME' column into hyperlinks.

$grid->updateColumn ('Name',array("decorator"=>"<a href='myproject/mycontroller/reportplot?id={{id}}&page=$page target='_parent' style='text-decoration:none; '>{{Name}}</a>"));

There is another column 'AGE'. I need to convert all the names into hyperlinks only where the 'AGE' is 20. Other Names will not be hyperlinks.

Is it possible to do somehow using a condition or is there any command??

Please suggest. Thanks in advance.

1 Answers1

0

You can use a Callback function to achieve this. Pass parameters to function, do the required calculations and pass it back to grid

$grid->updateColumn('Name', array('callback' => (array('function' => array($this, 'calculateAge'), 'params' => array('{{age}}','{{name}}')))));

    function calculateAge($age,$name){
    if($age>20){
    $name = '<a href="your_link">{{$name}}</a>'; 
    return $name;
    }

    }
Yamuna
  • 71
  • 1
  • 2
  • 13