Hello all,
I’ve got the normal grid and I just want to implement the print to pdf function. However when I use the code below I get an alert error without any text appearing on the page with the grid. And this error on the page when I try to print anyway:
/dhtmlx/codebase/grid-pdf-php/generate.php at 13 : Undefined index: grid_xml
Here is my code for the connector:
<?php
require_once("config.php");
$res=mysql_connect($mysql_server,$mysql_user,$mysql_pass);
mysql_select_db($mysql_db);
require("../../dhtmlx/codebase/connector/grid_connector.php");
require("../../dhtmlx/codebase/convert.php");
$convert = new ConvertService("../../dhtmlx/codebase/grid-pdf-php/generate.php");
$convert->pdf();
$gridConn = new GridConnector($res);
$gridConn->set_config(new GridConfiguration());
$sql = "SELECT * FROM customer_billing";
$gridConn->render_sql($sql,"id", "id, company_name, address, city, province, postal_code, phone_number, fax_number, web_address, longitude, latitude");
?>
And here is the code for the actual grid:
<script src="../../dhtmlx/codebase/dhtmlx.js" type="text/javascript"></script>
<!-- dhtmlx.css contains styles definitions for all included components -->
<link rel="STYLESHEET" type="text/css" href="../../dhtmlx/codebase/dhtmlx.css">
<script src="../../dhtmlx/codebase/connector/connector.js" type="text/javascript"></script>
<script src="../../dhtmlx/codebase/ext/dhtmlxgrid_export.js" type="text/javascript"></script>
<script type="text/javascript">
var layout,toolbar,custBillGrid;
dhtmlx.image_path = "../../dhtmlx/codebase/imgs/";
dhtmlxEvent(window,"load",function(){
//layout
layout = new dhtmlXLayoutObject("layout","1C");
layout.cells("a").setText("Customer");
layout.cells("a").setWidth(400);
toolbar = layout.attachToolbar();
toolbar.setIconsPath("../../icon/");
toolbar.loadXML("../../dhtmlx/codebase/xml/customer_billing_master.xml");
custBillGrid = layout.cells("a").attachGrid();
//contactGrid.setImagePath("./codebase/imgs/");
//contactGrid.setSkin("dhx_skyblue");
custBillGrid.setHeader("Account Number, Company Name, First Name, Last Name, Address, City, Province, Postal, Phone Number, Latitute, Longitude");
custBillGrid.attachHeader("#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter,#text_filter");
custBillGrid.setInitWidths("130,130,130,130,130,130,130,130,130,130,130");
custBillGrid.setColAlign("left,left,left,left,left,left,left,left,left,left,left");
custBillGrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro");
custBillGrid.setColSorting("str,str,str,str,str,str,str,str,str,str,str");
custBillGrid.enableSmartRendering(true);
custBillGrid.init();
custBillGrid.load("customer_billing_master_connector.php");
//toolbar
toolbar.addText("exportPDF", 1,'<a href="../../dhtmlx/codebase/grid-pdf-php/generate.php">Print to PDF</a>');
toolbar.addText("newCust", 2,'<a href="customer_billing_add.php"><img src="../../icon/savesmall16.png" width="18" height="18"/></a>');
toolbar.attachEvent("onclick",function(id){
if(id=="delCust"){
var rowId = custBillGrid.getSelectedRowId();
if(rowId!=null){
var selectedIndex = custBillGrid.getRowIndex(rowId)
custBillGrid.deleteRow(rowId);
if(selectedIndex!=(custBillGrid.getRowsNum()-1)){
custBillGrid.selectRow(selectedIndex+1,true);
}
else{
custBillGrid.selectRow(selectedIndex-1,true)
}
}
}
});
var dpg = new dataProcessor("customer_billing_master_connector.php");
dpg.init(custBillGrid);
})
</script>
<div id="layout" style="width:500px; height:500px; position:relative;"></div>
</div>
Hope someone can help me here. Thanks in advance