I have a grid that displays contact names. I want to be able to have a details button that links to another page(details), which will display the contact details such as , name, addresss, notes, etc...
I know how to add the button to the grid but I'm looking to see what the best approach would be to display the details page. I've seen a form with read-only data and I've also seen making a custom template. I'm sure there are use cases for both. What is the best one?
And lastly, how do i pass the id to the linked page?
Any help would be appreciated.
I'll not give full featured answer right now (not on my development laptop now), but in short:
You can use "expander" type of grid column. $grid->addColumn('expander',...);
You can use "button" type of grid column $b=$grid->addColumn('button',...) and add some code when button is clicked like if($b->isClicked()){...}.
In both cases you'll receive $_GET[xxx] parameter with ID of grid row record, where xxx is name of expander/button column set in addColumn() method.
You can use new add-on Romans made some weeks ago. It's about how to open "inner page" - new popup page which is "injected" in parent page class.
Edit: If you want to simply redirect to details page with id=xxx set, then you can do like this:
// Add button column to grid
$grid->addColumn('button','details','Details');
// Action to do when details button is clicked
// This must return JavaScript (use execute() method to do that immediately)
if(isset($_GET['details'])) {
// redirect to page foo/bar&id=xxx
$this->js()->univ()
->location($this->api->url('foo/bar',array('id'=>$_GET['details'])))
->execute();
}
You can also use redirect(url,callback) or redirectURL(url,callback) instead of location(url) if you need some JS callback functionality.