time in one row should not overlap with time in another row.

hi
could anyone throw some light on how do i convert the following code (which is more of C syntax) into grids

for(i=0;i<3;i++){
int k=From_time[i] //value of cell named from_time of row 'i'
  for(j=i+1;j<4;j++){
    int l =To_time[j] //value of cell named to_time of row 'j'
     if(l>k) success
     else fail
  }
}

Basically i need to compare column 2 of row 1 with column 1 of row 2 and like viz… i.e. Assuming rows are in ascending order, column 2 value of any row should be less than column 1 value of next row.each row should check with other 3 rows.
Example:
Row 1 5:00 6:00
Row 2 7:00 8:00
Row 3 9:00 10:00
Row 4 11:00 12:00
Success Condition
but if
Row 1 5:00 6:00
Row 2 5:45 8:00
Row 3 7:30 10:00
Row 4 9:00 12:00
–Should Fail

how about this…

var error = 0;

for (var i=1; i<grid.getRowsNum(); i++){
// starting form second row on the grid

         endtime = grid.cells(i-1,2).getValue());
         starttime = grid.cells(i,1).getValue());
         if (endtime > starttime) {
                error = error + 1;
         }
    }

thank u.

hi
In the above code, ‘i’ is row no and not row id but it works for grid.cells(i,index).getvalue();
In the conditional loop, i.e. in if(end_time>from_time), i actually got to change the cell background color, which i thought of achieving using setCellTextStyle(rowid,index,“background-color:white;”) function, but was struck as i am unsure if the function works with row no instead of rowid as its parameter, can you please confirm if this works or provide me an alternative to achieve the same.

Regards,
Narina

function compare_row_time()
{
var status_flag =false;
 for (var i=1; i<grid.getRowsNum(); i++)
 { 
   var tt_row=grid.cells(i-1,2).getvalue(); 
   var ft_row=grid.cells(i,1).getvalue();
   var tt_split=tt_row.split(":");
   var ft_split=ft_row.split(":");
      if (tt_split[0] > ft_split[0]) 
       {
	    grid.setCellTextStyle(i,1,"background-color:white;");
        }					
     else if((ft_split[0]*1 == tt_split[0]*1) && (ft_split[1]*1 > tt_split[1]*1))
	{
	    grid.setCellTextStyle(i,1,"background-color:white;");
	}
     else
	{
	    grid.setCellTextStyle(i,1,"background-color:yellow;");
	    status_flag = true;
	}
     }
    	return status_flag;
}

//onclick event:
	function save()
	{
	 if(!compare_row_time())
           {
	     myDataProcessor.sendData();
	   }
	 if(err_str!="")
	 jAlert('info',err_str,'Error Message');
	 err_str="";
	  $("#result").html("&nbsp;");
	}

this is not working.im getting error->_childindexes is NULL or not an Object.

if i take
for(var i=1;i<mygrid.getRowsNum().length;i++);//im not getting error

but the for loop is not working & when i alert values of end time and start time. im not getting the values.

but it returns undefined.

function compare_row_time()
{
 var status_flag=false;
 for(var i=1;i<mygrid.getRowsNum();i++)//CHECKING FROM 2ND ROW
  {
    var tt_row=mygrid.cells2(i-1,2).getValue();//i=1-1=0,CELL INDEX-2(TO-TIME)
	var ft_row=mygrid.cells2(i,1).getValue();//i=1,CELL INDEX-1(FROM-TIME)
	var tt_split=tt_row.split(":");
	var ft_split=ft_row.split(":");
	var id_samp=mygrid.getRowId(i);
	if(ft_split[0]*1 > tt_split[0]*1)
		{
			mygrid.setCellTextStyle(id_samp,1,"background-color:white;");
		}					
	else if((ft_split[0]*1 == tt_split[0]*1) && (ft_split[1]*1 > tt_split[1]*1))
		{
			mygrid.setCellTextStyle(id_samp,1,"background-color:white;");
		}
	else if(ft_row!="")
		{
			mygrid.setCellTextStyle(id_samp,1,"background-color:#FFFF99;");
			if(err_str!="")
					err_str+="\n"+(i+1)+".TIME SHOULD NOT OVERLAP.";
				else
					err_str=(i+1)+".TIME SHOULD NOT OVERLAP.";
			 status_flag = true;
		}
   }
     return status_flag;
 }

function save()
	{
	if(!compare_row_time())
	{
	  myDataProcessor.sendData();
        }
	 if(err_str!="")
	alert(err_str);
	 err_str="";
	}

the above function works when types are in sequence,but if i change the sequence it will fail.
eg:

type ftime ttime
f1 5:00 7:00
f2 12:00 2:00
f4 20:00 22:00
f3 12:30 13:30

when check with the function compare_row_time()

this example fails.

please suggest me how to do when type is not in sequence.

regards
narinas.