Exporting to PDF with multiple tabels

QuestionsExporting to PDF with multiple tabels
Alex asked 9 years ago

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";

1 Answers
Abu Ghufran answered 9 years ago

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

Your Answer

9 + 2 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?