Hello,
in my grid I am displaying columns from multiple tables. I am not showing the foreign key in the grid but a column called 'Name'.
However I try to export to PDF it is only showing the foreign keys in the pdf file.
How can I make it display the 'Name'-column in the pdf which is shown in the grid?
I guess this is some problem with the dropdown box i am using to display these two columns.
Here is some of my code:
$col = array();
$col["title"] = "Konto";
$col["name"] = "Konto_ID";
$col["dbname"] = "konten.id";
$col["width"] = "200";
$col["editable"] = true;
$col["hidden"] = false;
$col["edittype"] = "select";
$str = $g ->get_dropdown_values("select distinct ID as k,Name as v from konten");
$col["editoptions"] = array("value" => $str);
$col["formatter"] = "select";
$cols[] = $col;
$col = array();
$col["title"] = "Buchungsgruppe";
$col["name"] = "BGruppe_ID";
$col["dbname"] = "bgruppen.id";
$col["width"] = "200";
$col["editable"] = true;
$col["hidden"] = false;
$col["edittype"] = "select";
$str = $g ->get_dropdown_values("select distinct ID as k,Name as v from bgruppen");
$col["editoptions"] = array("value" => $str);
$col["formatter"] = "select";
$cols[] = $col;
$grid["export"] = array("filename"=>"my-file", "heading"=>"Invoice Details", "orientation"=>"portrait", "paper"=>"a4");
$g->select_command = "SELECT `buchungen`.`ID`, `buchungen`.`Datum`, `buchungen`.`Betrag`,
`buchungen`.`Verwendungszweck`, `buchungen`.`Art`,
`konten`.`ID` as 'Konto_ID',`bgruppen`.`ID` as 'BGruppe_ID'
FROM `buchungen` INNER JOIN `bgruppen`ON buchungen.BGruppe_ID = bgruppen.ID
INNER JOIN konten ON buchungen.Konto_ID = konten.ID";
You can use label as key convention in sql: "c.name as client_id"
$g->select_command = "SELECT i.id, invdate, c.name as client_id FROM invheader i
INNER JOIN clients c ON c.client_id = i.client_id";
Code: http://phpgrid.org/demo/demos/export/export-excel.phps
Demo: http://phpgrid.org/demo/demos/export/export-excel.php