New Grid Column Types – "button" and "ask"
With the migration to jQuery (UI) we have received lot of new fancy functionality, but some of the old things stopped worked too. However old stuff is fixable, and if there is anything – please let me know by commenting and I’ll give it a fix.
This tip explains how you can add buttons to the grid. You can see working demo here:
http://atk4.agiletech.ie/grid_columns.html
First you need to add a grid with this code:
$g=$this->add('Grid')
->addColumn('text','name','Name')
->addColumn('text','surname','Surname')
->addColumn('text','email','Email')
;
And we will need to also add 2 columns to demonstrate new features:
$g->addColumn('button','poke','Poke user');
$g->addColumn('prompt','message','Send message');
New column types are implemented inside lib/Grid.php and when clicked they will send ajaxec() request back to the same page with argument same as column name containing ID of the record. We need to properly handle that and return javascript output:
if($_GET['poke']){
$this->js()->univ()->alert('You have just poked '.$this->sample_grid_data[$_GET['poke']-1]['name'])->execute();
}
if($_GET['message']){
$this->js()->univ()->alert('You have sent message '.$_GET['value'].' to '.$this->sample_grid_data[$_GET['message']-1]['name'])->execute();
}
You can inspect how the formatters are implemented in lib/Grid and you can add your own grid column to add your own interactions.


link seems missing /
also, alerts not show up in safari.
just to clarify, _GET['poke'] would contain row id on which button was added?