true)? Or maybe there is other way to generate this column durrin" /> true)? Or maybe there is other way to generate this column durrin" /> true)? Or maybe there is other way to generate this column durrin"/>

Jqgrid PHP - export pdf with row numbers column

215 views Asked by At

Hi is there any option to export ordinal numbers column in jqgrid PHP ("rownumbers"=>true)? Or maybe there is other way to generate this column durring export?

Thanks in advance

$grid->setPdfOptions(array(
    "page_orientation" => "L",
    "grid_row_height"=>10,
    "page_format"=>"A4",
    "shrink_cell"=>false,
    "reprint_grid_header"=>true, 
    "font_size_main"=>16,
    "font_size_data"=>7,
    "font_name_data"=>"freeserif", 
    "font_name_main"=>"freeserif",
    "font_monospaced"=>"freeserif",
    "header"=>true, 
    "margin_top"=>15, 
    "header_logo"=>"logo.gif",
    "header_logo_width"=>40, 
    "header_title"=>$_COOKIE['data'],
    "footer"=>true
));
1

There are 1 answers

5
Tony Tomov On

In the current implementation there is no build in way to do this. You can simulate the row numbers in the select statement where this field in normal work can be hidden and when a export is performed to show it.

In order to have practical solution it is needed to know the database used like MySql, Postgree Sql or other.

UPDATE: In case of MySql you can try the following

// 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");
// reset variable
$conn->query('SET @row_number = 0');
$grid = new jqGridRender($conn);
$grid-SelectCommand = "SELECT (@row_number:=@row_number + 1) AS num, field1, field2 FROM table";
...
$exportme = false;
if($grid->oper == 'pdf') {
    $exportme = true;
}

...
$grid->setColProperty("num", array("hidden"=>!$exportme));