Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Bracco on Sep 29, 2008 00:54
open dhtmlx forum
TreeGrid submit problem

Hi,
this is the jsp where i place the grid:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%@page import="com.alisea.web.app.servlet.Constants"%>
<html>
<head>
    <title></title>
    <script language="javascript" src="js/tree/dhtmlXCommon.js"></script>
    <script language="javascript" src="js/tree/dhtmlXGrid.js"></script>
    <script language="javascript" src="js/tree/dhtmlXGridCell.js"></script>
    <script language="javascript" src="js/tree/dhtmlXTreeGrid.js"></script>
    <script language="javascript" src="js/tree/dhtmlXGrid_drag.js"></script>
<script language="javascript" src="js/tree/dhtmlXGrid_math.js"></script>
<script language="javascript" src="js/tree/dhtmlXGrid_form.js"></script>
<link rel="STYLESHEET" type="text/css" href="css/alisea.css">
    <link rel="STYLESHEET" type="text/css" href="css/dhtmlXGrid.css">
    <script language="javascript" src="js/aliseaweb.js"></script>
    <script language="javascript" src="js/ajax.js"></script>

</head>
<style>
    body {font-size:12px}
    .{font-family:arial;font-size:12px}
    h1 {cursor:hand;font-size:16px;margin-left:10px;line-height:10px}
    xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
    div.hdr{
        background-color:lightgrey;
        margin-bottom:10px;
        padding-left:10px;
    }
</style>
<body>
<form name="form1" action="Add_Azienda_Unita_locale.do">
    <table width="800">
        <tr>
            <td colspan="2">
                <div style="overflow:hidden" id="gridbox" width="100%" height="250px" style="background-color:white;"></div>
            </td>
        </tr>

        <tr>
            <td colspan="2">
                <div style="overflow:hidden" width="100%" height="250px" id="gridbox2" style="background-color:white;"></div>
</td>
        </tr>
        <tr>
            <td>
            <input name="Inserisci" type="button" value="Inserisci Aziende/Unita Locali nel profilo utente" onclick="saveandclose();" class="btn" onMouseOver="hov(this,'btn btnhov');" onMouseOut="hov(this, 'btn');">
            </td>
            <td>
            <input name="Delete Row" type="button" value="Cancella riga inserita nella tabella utente" onclick="deleteandcommit();" class="btn" onMouseOver="hov(this,'btn btnhov');" onMouseOut="hov(this, 'btn');">
            </td>
        </tr>
    </table>


<input type="hidden" name="_XML_AZIENDE_UL" id="_XML_AZIENDE_UL" value="<%=request.getAttribute(Constants._XML_AZIENDE_UL)%>">
<input type="hidden" name="_XML_AZIENDE_UL_UTENTE" id="_XML_AZIENDE_UL_UTENTE" value="<%=request.getAttribute(Constants._XML_AZIENDE_UL_UTENTE)%>">
<input type="hidden" name="fun" value="">
<input type="hidden" name="_XML_AZIENDE_UL_MOD_UTENTE" id="_XML_AZIENDE_UL_MOD_UTENTE" value="">
</form>
<script>
        var az_ul = document.getElementById("_XML_AZIENDE_UL").value;
        mygrid = new dhtmlXGridObject('gridbox');
        mygrid.selMultiRows = true;
        mygrid.imgURL = "imgs/";
        mygrid.setHeader("Aziende/Unita Locali");
        mygrid.setInitWidths("675");
        mygrid.setColAlign("left");
        mygrid.setColTypes("tree");
        mygrid.setColSorting("str");
        mygrid.enableDragAndDrop(true);
        mygrid.attachEvent("onEditCell",function(stage,id,index){
            if(index==0) return false /*deny editing*/
            return true});
        mygrid.init();
         mygrid.loadXMLString(az_ul);


        var az_ul_ut = document.getElementById("_XML_AZIENDE_UL_UTENTE").value;
         mygrid2 = new dhtmlXGridObject('gridbox2');

        mygrid2.selMultiRows = true;
        mygrid2.imgURL = "imgs/";
    mygrid2.setHeader("Aziende/Unita Locali Utente");
    mygrid2.setInitWidths("675");
    mygrid2.setColAlign("left");
    mygrid2.setColTypes("tree");
    mygrid2.setColSorting("str");
    


mygrid2.enableDragAndDrop(true);
mygrid2.attachEvent("onEditCell",function(stage,id,index){
            if(index==0) return false /*deny editing*/
            return true});
    
    
        mygrid2.init();
         mygrid2.loadXMLString(az_ul_ut);

    
</script>
<script type="text/javascript">

        function saveandclose()
        {
    
            //mygrid2.formCreateInputCollection();
            document.form1.fun.value='inseriscimodifiche';
            document.forms[0].submit();
            window.close();
        }


        function deleteandcommit()
        {
            var lista_figli = mygrid2.getSelectedId();
            if ( (null === lista_figli || lista_figli=="" || lista_figli=="null")) {
                alert("Seleziona una azienda o una unità locale da eliminare");
            }
            else
            {
                if(confirm("Sicuro di voler cancellare l'utente (" + lista_figli + ") selezionato?")){
                    var lista_padri = "";
                    var inizio = 0;
                    if(lista_figli.indexOf(",")!= -1){
                        while(lista_figli.indexOf(",")!= -1)
                        {
                            var pos = lista_figli.indexOf(",");
                            var figlio = lista_figli.substr(inizio,pos-1);
                            var padre = mygrid2.getParentId(figlio);
                            if(inizio==0){
                                lista_padri += padre;
                            }
                            else
                            {
                                lista_padri += ","+padre;
                            }
                            inizio = pos+1;
                        }
                    }
                    else
                    {
                        var parent = mygrid2.getParentId(mygrid2.getSelectedId());
                    }
                    mygrid2.deleteSelectedItem();
                    go("Add_Azienda_Unita_locale.do", "cancellaUtente");
            }
            }
        }
    </script>
</body>
</html>

When i click on the submit button i cant found the [GRIDID]_ROWS_ADDED and [GRIDID]_ROWS_DELETED parameter on the server side. As you can see i also used mygrid2.formCreateInputCollection(); but nothing change.
Can you help me?
Thank you.

Answer posted by Support on Sep 29, 2008 15:51
The code looks correct
There are two possible reasons of problem
a) you are using dhtmlxgrid 1.5 ( it not supported sending info about added||deleted rows. You need update to 1.6 ( technicallly you need to update dhtmlxgrid_form.js to one from version 1.6, all other can be preserved to prevent any unrequired changes ) 
b) the mode was not auto-enabled ( not sure how it may occurs ) - please try to add next line to the grid's init
     grid.submitAddedRows(true)
If it will throw js error - you are using old version of extension for sure.