0

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 Answers1

0

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));
Tony Tomov
  • 3,122
  • 1
  • 11
  • 18
  • Thank you for answear. About select statement I know how to do this, but there is a problem, when I use a filters or search, i'll probably lost numerological hierarchy then. – Marcin Brach Jan 24 '18 at 07:45
  • Database is build in MySql – Marcin Brach Jan 24 '18 at 09:49
  • Thanks again for an update, but this solution works exacly as i thought, when i try to export search results i'm loosing hierarchy. I need a method to generete this column just before export only for rows meeting search requirements. – Marcin Brach Jan 28 '18 at 01:52
  • In this case it is recommended to see a working example, which demonstrates the problem. What you exactly mean - I loose the hierarchy? – Tony Tomov Jan 28 '18 at 16:31
  • By hierarchy I ment it losing numreological order in row number column after I use sort, or serach option in jqgrid. – Marcin Brach Jan 29 '18 at 09:53