Here is the code:
function initGrid()
{
mygrid = layOut.cells("b").attachGrid();
mygrid.setImagePath("/NipoElectronics/jScript/dhtmlXAll/imgs/");
mygrid.enableLightMouseNavigation(true);
var geoCodedPlace ="<div id='gp'><a href='javascript:doBeforeReverseGeocoding();'>Населено място/Обект</a></div>";
var litresH100Column;
if(gup('stopsControl') == '0') litresH100Column = "<div>Литри/100</div>";
else if(gup('stopsControl') == '1') litresH100Column = "<div>Литри/100/h</div>";
else litresH100Column = "<div>Литри/100</div>";
mygrid.setHeader("-,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan,#cspan");
mygrid.attachHeader("<div align='center'>Период</div>,#cspan,Движение,Престой," + geoCodedPlace + ", Разтояние/км,Разход/л," + litresH100Column + ",Следа,#cspan");
mygrid.setInitWidths("90,90,80,80,*,100,100,80,20,50");
mygrid.setColAlign("center,center,center,center,left,left,left,left,left,left");
mygrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ch,img");
mygrid.setSkin("dhx_skyblue");
mygrid.init();
var urlParameters = "vehicleId="+gup('vehicleId')+"&startDate="+gup('date')+"&stopsControl="+gup('stopsControl')+"&stopPlaces="+gup('stopPlaces')+"&accuracy="+gup('accuracy')+"&firmName="+gup('firmName')+"&type=day_report";
var gridQString = "/NipoElectronics/RouteReportsServlet?"+urlParameters;
//dhtmlxError.catchError("LoadXML", ajaxErrorHandler);
mygrid.loadXML(gridQString);
mygrid.attachEvent("onXLE",function()
{
layOut.progressOff();
buildGridTitle();
buildGridFooter();
mygrid.setSizes();
});
mygrid.objBox.style.overflowX="hidden";
}
Here is the the final part:
[code]function buildGridTitle()
{
var formatedDate = mygrid.getUserData("", “formatedDate”);
var startWorkTime = mygrid.getUserData("", “startWorkTime”);
var endWorkTime = mygrid.getUserData("", “endWorkTime”);
var vehicleId = mygrid.getUserData("", “vehicleId”);
var workTime = startWorkTime + " - " + endWorkTime;
var tableTitle = "Дневен пътен лист за: <span id='s1' style=\"color:red;\">" + formatedDate + "</span> Работно време: <span id='s2' style=\"color:red;\">" + workTime + "</span> Кола: <span id='s3' style=\"color:red;\">" + vehicleId + "</span>";
var centeredTitle = "<div align='center'>" + tableTitle + "</div>";
mygrid.setColumnLabel(0,centeredTitle,0);
}[/code]
function buildGridFooter()
{
var titleDiv = "<div style='color:red;font-weight:bold'>Общо:</div>";
var allTime = "<div style='color:red;font-weight:bold'>" + mygrid.getUserData("", "allTime"); + "</div>";
var movingTime = "<div style='color:red;font-weight:bold'>" + mygrid.getUserData("", "movingTime"); + "</div>";
var idleTime = "<div style='color:red;font-weight:bold'>" + mygrid.getUserData("", "idleTime"); + "</div>";
var distance = "<div style='color:red;font-weight:bold'>" + mygrid.getUserData("", "distance"); + "</div>";
var fuel = "<div style='color:red;font-weight:bold'>" + mygrid.getUserData("", "fuel"); + "</div>";
var fuel100 = "<div style='color:red;font-weight:bold'>" + mygrid.getUserData("", "fuel100"); + "</div>";
var startWorkDay = mygrid.getUserData("", "startWorkDay");
var startWorkTime = mygrid.getUserData("", "startWorkTime");
var endWorkDay = mygrid.getUserData("", "endWorkDay");
var endWorkTime = mygrid.getUserData("", "endWorkTime");
var dreif = mygrid.getUserData("", "dreif");
var vehicleId = mygrid.getUserData("", "vehicleId");
var trace = "<div style=\"color:red;font-weight:bold\"><a href=\"javascript:void(0)\" onclick=\"doVisualization('"+ startWorkDay + "'\\,'" + startWorkTime + "'\\,'"+ endWorkDay +"'\\,'"+ endWorkTime +"'\\,'"+ vehicleId +"'\\,'"+ dreif +"'\\,'fullDay')\">\>\>\></a></div>";
mygrid.attachFooter(titleDiv + "," + allTime + "," + movingTime +"," + idleTime+ ", ," +distance+ "," + fuel + "," + fuel100 + "," + trace + ",#cspan");
}
and finally the VERY problem is this:
- when exporting to Excel it works but puts the footer before the rows.
- when hiding some rows it throws IndexOutOfBoundsException on the server.
- export to PDF does not work at all ( it throws IndexOutOfBoundsException = -1 ) on the server.
So any suggestions?