2015-05-07 70 views

回答

-1

出口,你可以試試這個 這是在哪裏顯示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更多的方便

enter link description here

您可以嘗試查看有關jqgri更多示例的文檔d

+0

您的回答不符合OP要求? – Husam