Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by HZGF on May 21, 2008 18:07
open dhtmlx forum
Got a Problem with sendData()

Hey guys, im new in dhtmlx and think its great but i got one problem with the sendData() Function.

I have two grids, i select some values from one an drag it to the other one and then editing it a bit.
After ive done all my edits i want mygrid3 to be saved in a text file (just at the moment while testing:) )
but i cant get it work. May its just a stupid typo or a big mistake of mine. here is my code:

html file:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
    <title>Drag and Drop between Grids</title>
    
    <link rel="STYLESHEET" type="text/css" href="dhtmlxgrid.css">
    
    <script src="dhtmlxcommon.js"></script>
    <script src="dhtmlxgrid.js"></script>        
    <script src="dhtmlxgridcell.js"></script>    
    <script src="dhtmlxgrid_drag.js"></script>
</head>

<body>
<link rel='STYLESHEET' type='text/css' href='style.css'>

    <table width="800px">
        <tr>
<td>
                <div id="gridbox2" width="165px" height="250" style="background-color:white;"></div>
</td>
            <td>
                <div id="gridbox3" width="480px" height="250" style="background-color:white;"></div>
            </td>
        </tr>
    </table>

<a href="javascript:void(0)" onclick="myDataProcessor.sendData()">Speichern</a>
<input type="button" value="Speichern" class="btn" onClick="myDataProcessor.dataprocessor.sendData();">

<script>


        mygrid2 = new dhtmlXGridObject('gridbox2');
        mygrid2.selMultiRows = true;
        mygrid2.setImagePath("imgs/");
        var flds = "Spielername,Gelb,Gelb/Rot,Rot";
        flds += ",Tore,Vorlagen,Note";
        mygrid2.setHeader(flds);
        mygrid2.setInitWidths("150,0,0,0,0,0,0,0")
        mygrid2.setColAlign("left,center,center,center,center,center,center")
        mygrid2.setColTypes("ed,ch,ch,ch,ed,ed,ed");
        mygrid2.setColSorting("str,int,int,int,int,int,int")
        mygrid2.setColumnColor("white");
        mygrid2.setMultiLine(false);
        mygrid2.enableDragAndDrop(true);
        mygrid2.init();
         mygrid2.loadXML("dynscroll.php");

        mygrid3 = new dhtmlXGridObject('gridbox3');
        mygrid3.selMultiRows = true;
        mygrid3.setImagePath("imgs/");
        var flds = "Spielername,Gelb,Gelb/Rot,Rot";
        flds += ",Tore,Vorlagen,Note";
        mygrid3.setHeader(flds);
        mygrid3.setInitWidths("150,50,70,50,50,70,50,50")
        mygrid3.setColAlign("left,center,center,center,center,center,center")
        mygrid3.setColTypes("ed,ch,ch,ch,ed,ed,ed");
        mygrid3.setColSorting("str,int,int,int,int,int,int")
        mygrid3.setColumnColor("white")
        mygrid3.setMultiLine(false);
        mygrid3.enableDragAndDrop(true);
        mygrid3.init();
         mygrid3.loadXML("grid.xml");

        myDataProcessor = new dataProcessor("update.php");
        myDataProcessor.setUpdateMode("off");
        myDataProcessor.enableDebug(true);
        myDataProcessor.enableDataNames(true);
        myDataProcessor.init(mygrid3);


</script>

</body>
</html>



update.php:

<?php

session_start();
if(!isset($_SESSION["id"]))
    $_SESSION["id"] = microtime();
    

$fh = fopen('test.txt', 'w+');
fwrite($fh, "muh");
fwrite($fh, '$_GET["Spielername"] $_GET["Gelb"] $_GET["pubdate"] $_SESSION["id"]');
    
    fclose($fh);

?>



Thx for helping guys
Answer posted by Support on May 22, 2008 02:46
The problem caused by incorrect usage of
    myDataProcessor.enableDataNames(true);
This command will use column IDs as names for parameters ( not the header values ), but in your code there is no command, which assigns column IDs
    mygrid3.setHeader(flds);
    mygrid3.setColumnIds(flds);   // this row need to be added, to work with DataNames
Answer posted by HZGF on May 22, 2008 03:35
problem is, that the update.php isnt triggered at all. nothing happens. dont know why. is the way i use the buttons the right one?
Answer posted by Support on May 22, 2008 08:44

With you initialization , any operation in mygrid3 will be recorded by dataprocessor ( the new rows marked as bold, right ? )
But becuase you are set update mode to off - data sending must be triggered by manual call of

      myDataProcessor.sendData();

you are using

       myDataProcessor.dataprocessor.sendData

which is probably incorrect