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