Error message "Undefined offset: 1"

I am using filter in grid. Like

mygrid.loadXML(“grid_load.php”,
function(){
mygrid.attachHeader(“#rspan,

,
,#rspan,#rspan,#rspan”);
//set title filter field
document.getElementById(“title_flt”).appendChild(document.getElementById(“title_flt_box”).childNodes[0])
//set author filter field
var authFlt = document.getElementById(“author_flt”).appendChild(document.getElementById(“author_flt_box”).childNodes[0]);
populateSelectWithAuthors(authFlt);
//block sorting and resize actions for second row
mygrid.hdr.rows[2].onmousedown=mygrid.hdr.rows[2].onclick=function(e){(e||event).cancelBubble=true;}
mygrid.setSizes();
});

When I try to export to PDF it generate
“C:\AppServ\www\dhtmlxGrid\server\gridPdfGenerator.php at 170 : Undefined offset: 1”
message. Without having the Filter coding it works fine.

Why?

Hi.
Could you provide grid_load.php content?
By the way, make sure you are using the last export script version
viewtopic.php?f=23&t=20151

Hi Radyno ,

Thank you for your reply. I will check it and come back to you.

Thanks

Mathy :slight_smile:

I have a similar problem.
C:\Inetpub\extras\shoah\resources\dhtmlx\ext\exportpdf\gridPdfGenerator.php at 236 : Undefined offset: 10

You may see the page at:
extras.ha.uth.gr/shoah/el/grid.php?qid=70
If it’s all greek to you, just click the PDF link at the list!

By the way, on the same page the export to Excel does not work at all.

I use the dhtmlxgrid_export.js script from:
viewtopic.php?f=23&t=19975
and the engines from:
viewtopic.php?f=23&t=20151

It looks like you have too much #cspan elements in line:

mygrid.attachEvent("onXLE", function() { mygrid.attachFooter("Βρέθηκαν "+mygrid.getRowsNum()+" εγγραφές που ικανοποιούν τα κριτήρια που θέσατε,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan", ["text-align: left;"]); });

Try to remove two or three such elements, this might help you.

As I remove the #cspan from the footer the error remains, lowering the offset.

The point of the many #cspan is that the complete message should appear in a single line. This message states the number of records returned from the database. If you can point me on how to include that in the navigation (e.g. it now says “records 1 to 20”, to change it to "records 1 to 20 from 250) I can do without the footer.

But even if I comment out the footer the error does not go away:
C:\Inetpub\extras\shoah\resources\dhtmlx\ext\exportpdf\gridPdfWrapper.php at 141 : Undefined offset: 0

Update dhtmlxGridGenerator.php from attachment, please.

To improve grid appearance in PDF open dhtmlxgrid_export.js file and comment the follow line like here:

// if (empty_cols != grid._cCount)
	xml+="\n<columns>"+cxml+"</columns>";

gridPdfGenerator.zip (3.01 KB)

Excellent! It now works and displays perfectly.

The Excel export still doesn’t work. The debug.xml displays the data and has no errors in it.

Please, modify generate.php file (for excel export) like here:

<?php

error_reporting(E_ALL);
require_once 'gridExcelGenerator.php';
require_once 'gridExcelWrapper.php';


$debug = true;
//$error_handler = set_error_handler("PDFErrorHandler");

After that try to export grid. Does any error occur?