Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Eugene on Jan 21, 2010 16:55
open dhtmlx forum
printview in grid not working properly

when i use print view some of my rows are printing twice, code sample:
<!-- Main File -->
<input type="hidden" id="TimeStmp" value="<?php echo date("Y-m-d h:i:s");?>">
<div id="OutParts" style="width:365;height:135"></div>
<input type="button" onclick="addOutPart(OutPartsGrid.getRowsNum()+1,1,1,1,100)">
<input type="button" onclick="btnSaveClicked()">
<script>
    OutPartsGrid = new dhtmlXGridObject('OutParts');
    OutPartsGrid.setSkin("light");
    OutPartsGrid.seteditable=true;
    OutPartsGrid.enableEditEvents(false,false,false);
    OutPartsGrid.imgURL = "dhtmlxGrid/codebase/imgs/";
    OutPartsGrid.loadXML("OutParts.php?Tech=1", function(){});
    OutPartsGridProcessor = new dataProcessor("OutPartsUpdt.php?Tech=1&ts="+document.getElementById("TimeStmp").value);
    OutPartsGridProcessor.enableDataNames(true);
    OutPartsGridProcessor.setUpdateMode("off");
    OutPartsGridProcessor.defineAction("error",myErrorHandler);
    OutPartsGridProcessor.setTransactionMode("POST");
    OutPartsGridProcessor.init(OutPartsGrid);
    OutPartsGridProcessor.defineAction("debug", dpDebug);
    function addOutPart(id,type,qty,qtytotal,price){
        if (OutPartsGrid.getRowIndex(id)==-1){
            OutPartsGrid.addRow(id,type+"^javascript:delPartOut("+id+");^_self,"+qty+","+qtytotal+","+price,OutPartsGrid.getRowsNum()+1)
        }else{
            alert ("ATTENTION!!! THIS PART IS ALREADY IN THE LIST");
        }
        document.getElementById("PartOut").value=0;
        document.getElementById("QTYPartOut").value="1";
    }
    function btnSaveClicked(){
        OutPartsGridProcessor.sendData();
        setTimeout("gridsUpdate();",1250);
    }
    function gridsUpdate(){
       
        OutPartsGrid.parentGrid  = true;
        html = OutPartsGrid.printView();
        OutPartsGrid.parentGrid = null;
        win=window.open('','mywindow','width=800,height=500,scrollbars=yes');
        win.document.writeln(html);
   }

</script>

<!-- OutParts.php File -->
<?php
    usleep(500000);
    header("Content-type:text/xml");
    print('<?xml version="1.0" encoding="UTF-8"?>');
    print ("<rows>");
    print('<head>');
$head=explode(",","Part Type,QTY,Total,Price");
$size=explode(",","100,50,50,60");
$colType=explode(",","link,ed,ed,price");
$sorting=explode(",","na,na,na,na,na");
$i=0;
while ($i<4){
    print('<column id="'.$head[$i].'" width="'.$size[$i].'" type="'.$colType[$i].'" align="left" sort="'.$sorting[$i].'">'.$head[$i].' ');
    print('</column>');
    $i++;
}
    print('</head>');
//**********************
    print("</rows>");
?>

how can it be fixed, or what do i do wrong
Answer posted by Alex (support) on Jan 22, 2010 01:34