检查时间重叠
你好
我已经通过将值放入数组并对它们进行排序来检查时间的重叠.
在这里,当单元格为空时,我无法将数据插入单元格!
我的代码是:
选择 | 换行 | 行号
- <script>
- function compare_row_time()
- {
- var all_times= new Array();
- var flag_check=false;
- var count_times=0;
- for(var i=0;i<mygrid.getRowsNum();i++)
- {
- var time_1=mygrid.cells2(i,1).getValue();//starttime value of i
- var time_2=mygrid.cells2(i,2).getValue();//endtime value of i
- all_times[count_times]=time_1;
- count_times++;
- all_times[count_times]=time_2;
- count_times++;
- }
- var sort_times= new Array();
- sort_times=all_times.sort();
- for(var j=0; j<sort_times.length;j++)
- {
- if(sort_times[j]==sort_times[j+1])
- {
- flag_check=true;//if false data is inserted even it is wrong.
- }
- }
- return flag_check;
- }
- function save()
- {
- if(!compare_row_time())
- {
- myDataProcessor.sendData();//sending data to server
- }
- if(err_str!="")//error_msg
- alert(err_str);
- err_str="";
- }
- </script>
1.在排序时间数组中,如果存在任何重复值,它将显示错误(这仅在IM检查网格中的现有数据时有效)
2.如果im在空行中插入新值,im将无法发送数据(如果我在[排序时间数组]中将FLAG_CHECK更改为FALSE,则无法插入值,但如果我提供重复的值,数据也将被插入.此条件为FALSE)
3.我的时间模式是用户可以输入05:00或5:00的时间(如果一行的时间为5:00,而另一行的时间为05:00,则不进行比较;如果模式的类型相同,则会检查是否存在重复项)
4.如何突出显示重复的单元格并为其提供消息.
有人能在没有这些错误的情况下重建上面的代码吗?
谢谢.
问候
纳里娜