Hi Phpgrid people! sorry, a noob question…
table A [ id, name, age ] table B [ id, infotext ]
in app.php – with $g->table = “B”;
$col = array();
$col[“title”] = “Name”;
$col[“name”] = “name”; (this data must be taken from table A with id PK)
How can I show in a column, information from another table (with a select sql on “formatoptions” ?)
Option1: Select grid data using SQL join in select_command. e.g.
$g->select_command = “SELECT a.name,a.age,b.id,b.infotext FROM b INNER JOIN a on a.id=b.id”;
Then on display, you can use above code.
Option2: You can still avoid using select_command and use dropdown to lookup from other table. IF a.id = b.id (PK,FK)
$col[“name”] = “id”;
$col[“edittype”] = “select”; // render as select
$str = $g->get_dropdown_values(“select id as k, name as v from A”);
$col[“editoptions”] = array(“value”=>$str);
$col[“formatter”] = “select”; // display label, not value
Abu Ghufran - Dev Team
Grid 4 PHP Framework
We are sorry that this post was not useful for you!
Let us improve this post!
Tell us how we can improve this post?