0

I just started learning ATK.

In my project, I have a grid of a Model 'A'. There are many rows for Model 'A'.

I have a separate page for that Model that shows its details.

Now, I want, my grid rows clickable and it should redirect to that page with 'ID' as argument. So, I can get it and load it again. To show its details on that page.

How to achieve this?

Akshat
  • 720
  • 9
  • 24
  • This is doable what you're asking for, but why not simply using CRUD already fully implemented in ATK4? – DarkSide Mar 01 '14 at 13:49
  • But, I want its UI completely customized. CRUD/Grid may have button, but that's not much user friendly. If anyone want to see detail of that row, he will usually click on row, not a button on that row. – Akshat Mar 03 '14 at 08:42
  • Then you have to add small JavaScript onClick method on grid table row. Something like $grid->js(true)->univ()->find('tr')->click(function(){doSomething();}); – DarkSide Mar 03 '14 at 11:08

1 Answers1

0

It should be easily possible with ->on handler.

$page=$this->api->url('./subpage');

if($crud->grid) {
    $crud->grid->on('click','tr')->univ()->location(
        array($page, 'id'=>$this->js()->_selectorThis()->data('id'))
    );
}

if ->on() is not working in your version of toolkit, you can also use ->js('click')->_selector('#'.$crud->grid->getJSID().' tr')->univ()->location......;

Some documentation here:

https://github.com/atk4/atk4/blob/4.3/lib/AbstractView.php#L546

romaninsh
  • 10,606
  • 4
  • 50
  • 70