的示例
我是JQGrid PHP的新手。我可以将表数据导出到PDF格式。我的桌子有一个子网格。有什么方法可以将表格与subgrid一起导出到pdf?
导出您可以尝试这是显示jqgrid表的HTML页面:
<?php
require_once '../../../jq-config.php';
// include the jqGrid Class
require_once ABSPATH."php/jqGrid.php";
// include the driver class
require_once ABSPATH."php/jqGridPdo.php";
// LOAD lang file
require_once(ABSPATH.'/php/tcpdf/config/lang/eng.php');
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
$grid->SelectCommand = 'SELECT OrderID, OrderDate, CustomerID, ShipName, Freight FROM orders';
// Set output format to json
$grid->dataType = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('grid.php');
// Set some grid options
$grid->setGridOptions(array(
"rowNum"=>10,
"rowList"=>array(10,20,30),
"sortname"=>"OrderID",
"caption"=>"PDF export"
));
// Change some property of the field(s)
$grid->setColProperty("OrderDate", array(
"formatter"=>"date",
"formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"m/d/Y"),
"search"=>false
)
);
$grid->setColProperty("ShipName", array("width"=>"250"));
$grid->setColProperty("Freight", array("label"=>"Test", "align"=>"right"));
if($grid->oper == "pdf") {
$grid->setPdfOptions(array(
// reprint table header
"shrink_cell"=>false,
"reprint_grid_header" => true
));
}
// Enable navigator
$grid->navigator = true;
// Enable excel export
$grid->setNavOptions('navigator', array("pdf"=>true,"add"=>false,"edit"=>false,"del"=>false,"view"=>false, "excel"=>false));
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true);
?>
,或者您可以使用FPDF更简单
在此处输入链接说明
您可以尝试查看文档以获取更多jqgrid