atk4

ATK: Using link format with grid


I'm new with ATK, but couldn't find the solution for this. I found the example for using template on link here: https://agiletoolkit.org/whatsnew/apr2011

I create grid like this, and add link:

$grid=$this->add('Grid');
$grid->setModel('Application',array('name'));
$grid->addColumn('link','name')->setTemplate('<a href="..">xx</a>');

Which produces links like this:

<a href="..">xx</a>
<a href="..">xx</a>

I would like to achieve like this:

<a href="?name=1">Name 1</a>
<a href="?name=2">Name 2</a>

Can I achieve this with setTemplate? I should somehow insert current name and id value into template, but how to do this? Or is there some other, better way?


Solution

  • Try this

    $grid=$this->add('Grid');
    $grid->setModel('Application',array('name'));
    $grid->addColumn('link','name')->setTemplate('<a href=".."><?$name?></a>');