Problem in sending data through myDataProcessor.sendData();

hi i written validation for single row with the help of myDataProcessor.setVerificator(); and the function name is validate_grid(value,id,ind);this will be called on click of save button
and i want to compare data with two rows so i have written a custom validation function.
send_data()
when there is a validtion error in first row and second row is true the second row is submitted without completing validation the first row.

function send_data()
 {
  var status_flag=false;
  for(var i=(mygrid.getRowsNum()-1); i>0 ; i--)
  {
   var a_id=mygrid.getRowId(i);
   var b_id=mygrid.getRowId(i-1);
   var dp_date=mygrid.cellById(a_id,0).getValue();//departure date of second row.
   var av_date=mygrid.cellById(b_id,3).getValue();//arrival date of first row.
   var dep_time=mygrid.cellById(a_id,1).getValue();//departure time of second row.
   var arv_time=mygrid.cellById(b_id,4).getValue();//arrival time of first row.
   var d=dp_date.split("/");//split '/' in departure date.
   var dp=d[2]+"/"+d[1]+"/"+d[0];//& convert departure date(dd/mm/yyyy) to (yyyy/mm/dd) format.
   var t=av_date.split("/");//split '/' arrival date.
   var ap=t[2]+"/"+t[1]+"/"+t[0];//& convert arrival date(dd/mm/yyyy) to (yyyy/mm/dd) format.
   var dd=Date.parse(dp);//parse departure date.
   var ad=Date.parse(ap);//parse arrival date.
   var dt=dep_time.split(":");//split departure time.
   var at=arv_time.split(":");//split arrival time.
   
	if(dd==ad)//if depdate = arrival date check time validation
	{
	   if(dt[0]*1 > at[0]*1)
		{
			mygrid.setCellTextStyle(a_id,1,"background-color:white;");
		}
		else if((dt[0]*1 == at[0]*1) && (dt[1]*1 > at[1]*1))
		{
			mygrid.setCellTextStyle(a_id,1,"background-color:white;");
		}
		else
		{  
			mygrid.setCellTextStyle(a_id,1,"background-color:#FFFF99;");
			 if(err_str!="")
			   err_str+="\n"+"departure time should be greater than previous arrival time.";
				else
			   err_str="departure time should be greater than previoius arrival time.";
			status_flag=true;
		}
	}
	else if(dd>=ad)
	{
	  mygrid.setCellTextStyle(a_id,0,"background-color:white;");
	}
	else
	{
		mygrid.setCellTextStyle(a_id,0,"background-color:#FFFF99;");
		if(err_str!="")
		   err_str+="\n"+"departure date should be greater than previoius arrival date.";
			else
		   err_str="departure date should be greater than previoius arrival date.";
		status_flag=true;
	}
   }
 //to delete empty cells in a row except departure & arrival place  
 var i=mygrid.getRowsNum()-1;
 var a_id=mygrid.getRowId(i);
 if((mygrid.cells(a_id,0).getValue().length<=0) && (mygrid.cells(a_id,1).getValue().length<=0) && (mygrid.cells(a_id,3).getValue().length<=0) && (mygrid.cells(a_id,4).getValue().length<=0) && (mygrid.cells(a_id,6).getValue().length<=0))
 {
 mygrid.deleteRow(a_id);
 }  
 return status_flag;
}

in the save button

if(!send_data())
	{
	myDataProcessor.sendData();
	}

can any one tell me where i went wrong.thanks

Above code will result in data_sending if any row is valid, if you need to send data only when all rows are valid, you need to set
var status_flag=true;
at first line of your method, and set flag to false when validation is broken ( revert current logic basically )

hi stanislav its not working,even if i changed it to true.can u correct my code.

the validation is happing but if a row is valid first its getting submitted.

Check settings of dataprocessor, by default it is uses auto-update mode, so it will send data without direct sendData call.

Also, you have mygrid.deleteRow line in your function, which may mark row in question as deleted and initiate data sending, assuming that you have auto-update mode set.

[code]Actually im using
var dp = new DataProcessor(“some.php?field=”+field_name);
dp.setTransactionMode(“POST”,true);
dp.setUpdateMode(“off”);
dp.init(mygrid);
dp.setVerificator(0,validate_grid); -->[validation function]

and im send form data as
save()–>button onClick of save data will be submitted
{
dp.serverProcessor = “some_new_url”;
if(!send_data())—[this my validation function for comparing rows]
{
dp.sendData();
}
}
[/code]

The code of send_data looks valid, if any of rules failed - it must return true, which will block data sending. Can you add some logging code and check which value your function returns.

Init code of dataprocessor looks good as well, it must prevent auto-updates, so the only way to send data is by manual dp.sendData call.