Tag Archives: Export

before_script_end

before_script_end is not a function but a variable. It allows you to inject custom javascript before the end of jqGrid object closing script tag so all DOM elements are presented. This is considered an advanced way to manipulate your grid.

The following code snippet demonstrates using this variable to insert a javascript that creates a export dropdown menu on the bottom toolbar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
$dg3 = new C_DataGrid("SELECT * FROM products", "productCode", "products");

$exportDropdown =<<< EXPORTDROPDOWN
$('#products_pager1_left').append ('<div style=padding-right: 16px;>Export:\
    <select onchange=document.location.href=this.options[this.selectedIndex].value;>\
        <option>---</option>\
        <option value=/phpGridx/export.php?gn=products&export_type=excel>Excel</option>\
        <option value=/phpGridx/export.php?gn=products&export_type=pdf>PDF</option>\
        <option value=/phpGridx/export.php?gn=products&export_type=html>HTML</option>\
        <option value=/phpGridx/export.php?gn=products&export_type=csv>CSV</option>\
    </select></div>');
EXPORTDROPDOWN;

$dg->before_script_end = $exportDropdown;
$dg->display();
Comments ( 0 )

Excel, HTML, PDF, or CSV Export

phpGrid currently supports export in native Excel format, CSV, PDF, and HTML format. When the export feature is enabled, phpGrid displays an export icon in the footer. Also see enable_export().

PDF and CSV formats are now supported (Available to Professional License and up) !

export_icons

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
$dg = new C_DataGrid("SELECT * FROM orders", "orderNumber", "orders");
// change column titles
$dg->set_col_title("orderNumber", "Order No.");
$dg->set_col_title("orderDate", "Order Date");
$dg->set_col_title("shippedDate", "Shipped Date");
$dg->set_col_title("customerNumber", "Customer No.");
// hide a column
$dg->set_col_hidden("requiredDate");
// change default caption
$dg->set_caption("Orders List");
// EXCEL export
$dg->enable_export('PDF');
$dg->display();


$dg2 = new C_DataGrid("select * from customers", "customerNumber", "Customers");
// PDF export
$dg2->enable_export('EXCEL');
$dg2->display();

See Live Example!

Comments ( 0 )