Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Frank on Aug 26, 2009 11:36
open dhtmlx forum
dhtmlxGrid last row's setVerificator function not working


I am using dhtmlxGrid v.2.0 Professional edition build 81009/81107

when I add a new row, following 3 lines not working at grid's last row,
myDataProcessor2.setVerificator(0);
myDataProcessor2.setVerificator(1);
myDataProcessor2.setVerificator(1,validateEmail);


<head>
<title>addressbook</title>
<link rel="stylesheet" type="text/css" href="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.css" />    
    <script src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
<script type="text/javascript" src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
<script type="text/javascript" src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script>    
    <script src="../dhtmlxSuite/dhtmlxGrid/codebase/ext/dhtmlxgrid_srnd.js"></script>
    <script src="../dhtmlxSuite/dhtmlxGrid/codebase/ext/dhtmlxgrid_filter.js"></script>
    <script src="../dhtmlxSuite/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script>
<style>
.grid_hover {
background-color:#7FFFD4;
font-size:20px;
}
</style>    
<script>    
function addRow(){
var newId = (new Date()).valueOf();
mygrid.addRow(newId, ",,");


}

function removeRow(){
var selId = mygrid.getSelectedId()
if (selId == "")
{
alert("please select delete row !!");
return;
}
mygrid.deleteRow(selId);
}        

function validateEmail(value,colName) {
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/
//var reg = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
var address = value.toString()._dhx_trim();
if(reg.test(address) == false)
{
alert('Email format error!!');
return false;
}
else
            return true;
}
    </script>    
</head>

<body style="margin: 0px; ">
<center>
<table width='80%' height='100%'>
<tr>
<td width='70%'>
<div id="mygrid_container" style="width:100%;height:100%;overflow:auto;"></div></td>
<td width='30%' valign="top">
<button onclick="addRow();mygrid.selectCell(mygrid.getRowsNum() - 1,0, false, true, true);">add row</button><br />
<button onclick="removeRow()">delete row</button><br />
<button style="background-color:pink" onclick="myDataProcessor2.sendData();">save data</button>     
</td>
</tr>
</table>
</center>
<script>

var mygrid = new dhtmlXGridObject('mygrid_container');
mygrid.setImagePath("../dhtmlxSuite/dhtmlxGrid/codebase/imgs/");
mygrid.setHeader("Name,Email,Title");
mygrid.attachHeader("#text_search,#text_search,#text_search");
mygrid.setColumnIds("name,email,pos")
mygrid.setInitWidths("150,*,150");
mygrid.setColAlign("left,left,left")
mygrid.setSkin("modern");
mygrid.setColSorting("str,str,str");
mygrid.enableEditTabOnly(1);
mygrid.preventIECaching(true);
mygrid.enableRowsHover(true,'grid_hover')
mygrid.setActive(true);

mygrid.init();
mygrid.loadXML("addressbook_contactor_get.aspx");    

    
myDataProcessor2 = new dataProcessor("addressbook_contactor_update.aspx");
myDataProcessor2.setTransactionMode("POST");
myDataProcessor2.setUpdateMode("off");
myDataProcessor2.enableDebug(true);
myDataProcessor2.setVerificator(0);
myDataProcessor2.setVerificator(1);
myDataProcessor2.setVerificator(1,validateEmail);
    myDataProcessor2.init(mygrid);
</script>
</body>
</html>
Answer posted by dhxSupport on Aug 27, 2009 02:34
Please try to replace your dhtmlxdataprocessor.js file with file from attachment. If issue still occurs please provide us complete example where we can reproduce it. 
Attachments (1)
Answer posted by Frank on Aug 27, 2009 05:47

I set setUpdateMode("off"). User need press "savedata" button to senddata to server site

This version "dataprocessor" have following problems

1. after press "add row", all these setVerificator function not working ( if I add two rows or more, same situation)

2. after save the data, all these setVerificator function are working

3. column sorting function not working

Answer posted by dhxSupport on Aug 31, 2009 03:10
Unfortunately we cannot reproduce this issue locally. Please provide us complete example where we can reproduce it. 
Answer posted by Frank on Sep 01, 2009 05:05

My program as follow: aspx file with c#

<%@ Page Language="C#" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<script runat="server">

</script>

<html>
<head>
 <title>AddressBook</title>
    <link rel="stylesheet" type="text/css" href="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.css" /> 
 <script src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxcommon.js"></script>
    <script type="text/javascript" src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgrid.js"></script>
    <script type="text/javascript" src="../dhtmlxSuite/dhtmlxGrid/codebase/dhtmlxgridcell.js"></script> 
 <script  src="../dhtmlxSuite/dhtmlxGrid/codebase/ext/dhtmlxgrid_srnd.js"></script>
 <script  src="../dhtmlxSuite/dhtmlxGrid/codebase/ext/dhtmlxgrid_filter.js"></script>   
 <script src="../dhtmlxSuite/dhtmlxDataProcessor/codebase/dhtmlxdataprocessor.js"></script>
<style>
    .grid_hover {
        background-color:#7FFFD4;
        font-size:20px;
    }
</style> 
<script> 
  function addRow(){
   var newId = (new Date()).valueOf();
   mygrid.addRow(newId, ",,");
  }
 
  function removeRow(){
   var selId = mygrid.getSelectedId()
   if (selId == "")
   {
        alert("Please select delete row !!");
        return;
   }
   mygrid.deleteRow(selId);

  }  
 
    function validateEmail(value,colName) {
        var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/ 
        //var reg = /\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/
        var address = value.toString()._dhx_trim();
        if(reg.test(address) == false)
        {
                alert('email format error!!');
                return false;
        }
        else
   return true;       
   } 
 </script> 
</head>

<body style="margin: 0px; ">
<center>
<table width='80%' height='100%'>
<tr>
<td width='70%'>
<div id="mygrid_container" style="width:100%;height:100%;overflow:auto;"></div></td>
<td width='30%' valign="top">
<font style="font-size:11px;">please remember press[Save data]button。
</font><br />
<button onclick="addRow();(arguments[0]||window.event).cancelBubble=true;mygrid.selectCell(mygrid.getRowsNum() - 1,0, false, true, true);">新增資料行</button><br />
<button onclick="removeRow()">delete row</button><br />   
<button style="background-color:pink" onclick="myDataProcessor2.sendData();">Save data</button>   
</td>
</tr>
</table>
</center>
<script>
   
   var mygrid = new dhtmlXGridObject('mygrid_container');
   mygrid.setImagePath("../dhtmlxSuite/dhtmlxGrid/codebase/imgs/");
   mygrid.setHeader("group,name,email,title");
  
   mygrid.setColumnIds("dept,name,email,pos")
   mygrid.setInitWidths("150,*,250,150");
 
   mygrid.setColAlign("left,left,left,left")
   mygrid.setSkin("modern");
   mygrid.setColSorting("str,str,str,str");
   mygrid.enableEditTabOnly(1);
   mygrid.preventIECaching(true);
   mygrid.enableRowsHover(true,'grid_hover')
   mygrid.setActive(true);
          
   mygrid.init();
   mygrid.loadXML("addressbook_contactor_get.aspx");    //userInfo2.xml
//   mygrid.loadXML("userInfo2.xml");    //userInfo2.xml  

 
    myDataProcessor2 = new dataProcessor("addressbook_contactor_update.aspx");
    myDataProcessor2.setTransactionMode("POST");
    myDataProcessor2.setUpdateMode("off");   
//    myDataProcessor2.enableDebug(true);

    myDataProcessor2.setVerificator(1);   
    myDataProcessor2.setVerificator(2);    
    myDataProcessor2.setVerificator(2,validateEmail);
 myDataProcessor2.init(mygrid); 

</script>
</body>
</html>

addressbook_contactor_get.aspx will generate following xml string

<?xml version="1.0" encoding="utf-8"?>
<rows>
  <head>
    <column width="100" type="coro">group<option value="11">dpt1</option><option value="12">dpt1-1</option><option value="13">dpt2</option><option value="14">dpt2-1</option><option value="15">dpt-3</option><option value="16">dpt-31</option></column>
    <column width="100" type="ed">name</column>
    <column width="*" type="ed">email</column>
    <column width="120" type="ed">title</column>
  </head>
  <row id="1">
    <cell>12</cell>
    <cell>frank1</cell>
    <cell>aa@aa.mm</cell>
    <cell>pos1</cell>
  </row>
  <row id="5">
    <cell>12</cell>
    <cell>sss</cell>
    <cell>aa@ssf</cell>
    <cell />
  </row>
  <row id="3">
    <cell>13</cell>
    <cell>frank2</cell>
    <cell>dd@aa.vv</cell>
    <cell>pos2</cell>
  </row>
  <row id="4">
    <cell>14</cell>
    <cell>frank3</cell>
    <cell>cc@xx.cc</cell>
    <cell />
  </row>
</rows>

 

Attachments (1)