easyui datagrid rowedit点击编辑行

 onClickRow: function (index, rowData) { 
		    	
		    	//单击事件
		    	if (editIndexDutyVal != index){
					if (endEditing_update()){
						//开始编辑状态=beginEdit
						$('#mygrid').datagrid('selectRow', index).datagrid('beginEdit', index);
						editIndexDutyVal = index;
					} else {
						$('#mygrid').datagrid('selectRow', editIndexDutyVal);
					}
			    }
		    }

function endEditing_update(){
	
	        //alert("2-editIndexDutyVal="+editIndexDutyVal);
			if (editIndexDutyVal ==undefined){
				return true;
			}
			if ($('#mygrid').datagrid('validateRow', editIndexDutyVal)){
				//上午
				var ed0 = $('#mygrid').datagrid('getEditor', {index:editIndexDutyVal,field:'morningPeopleIds'});
				var morningPeopleNames = $(ed0.target).combotree('getText');
				var morningPeopleIds = $(ed0.target).combotree('getValues');//此处不用getValue,因为multiple:true
				var arr0=morningPeopleIds.toString().split(",");
				var morningPeopleIds_Reverse="";
				if(arr0.length>2){
					 $.messager.alert('系统提示','<font size=\"2\" color=\"#666666\"><strong>上午值班同志最多可以选择2个!</strong></font>','warningSunnyIcon');
				return false;	
				}else{
					//1,2和2,1一致没有修改
					if(arr0.length==2){
						morningPeopleIds_Reverse=arr0[1]+","+arr0[0];
					}else{
						morningPeopleIds_Reverse=arr0[0];
					}
				}
				if($.trim(tempdataSource[editIndexDutyVal].morningPeopleIds)==$.trim(morningPeopleIds)
						||$.trim(tempdataSource[editIndexDutyVal].morningPeopleIds)==$.trim(morningPeopleIds_Reverse)){
					$('#mygrid').datagrid('getRows')[editIndexDutyVal]['morningPeopleNames'] = morningPeopleNames;
				}else{
					$('#mygrid').datagrid('getRows')[editIndexDutyVal]['morningPeopleNames'] = 
						"<font color=\"#0033cc\" style=\"font-style:italic;font-weight:bold;\">"+morningPeopleNames+"</font>";
				}
				//下午
				var ed1 = $('#mygrid').datagrid('getEditor', {index:editIndexDutyVal,field:'afternoonPeopleIds'});
				var afternoonPeopleNames = $(ed1.target).combotree('getText');
				var afternoonPeopleIds = $(ed1.target).combotree('getValues');
				var arr1=afternoonPeopleIds.toString().split(",");
				var afternoonPeopleIds_Reverse="";
				if(arr1.length>2){
					 $.messager.alert('系统提示','<font size=\"2\" color=\"#666666\"><strong>下午值班同志最多可以选择2个!</strong></font>','warningSunnyIcon');
				return false;	
				}else{
					//1,2和2,1一致没有修改
					if(arr1.length==2){
						afternoonPeopleIds_Reverse=arr1[1]+","+arr1[0];
					}else{
						afternoonPeopleIds_Reverse=arr1[0];
					}
				}
				if($.trim(tempdataSource[editIndexDutyVal].afternoonPeopleIds)==$.trim(afternoonPeopleIds)
					||$.trim(tempdataSource[editIndexDutyVal].afternoonPeopleIds)==$.trim(afternoonPeopleIds_Reverse)){
					$('#mygrid').datagrid('getRows')[editIndexDutyVal]['afternoonPeopleNames'] = afternoonPeopleNames;
				}else{
					$('#mygrid').datagrid('getRows')[editIndexDutyVal]['afternoonPeopleNames'] = 
						"<font color=\"#0033cc\" style=\"font-style:italic;font-weight:bold;\">"+afternoonPeopleNames+"</font>";
				}
				//晚上
				var ed2 = $('#mygrid').datagrid('getEditor', {index:editIndexDutyVal,field:'eveningPeopleIds'});
				var eveningPeopleNames = $(ed2.target).combotree('getText');
				var eveningPeopleIds = $(ed2.target).combotree('getValues');
				var arr2=eveningPeopleIds.toString().split(",");
				var eveningPeopleIds_Reverse="";
				if(arr2.length>2){
					 $.messager.alert('系统提示','<font size=\"2\" color=\"#666666\"><strong>晚上值班同志最多可以选择2个!</strong></font>','warningSunnyIcon');
				return false;	
				}else{
					//1,2和2,1一致没有修改
					if(arr2.length==2){
						eveningPeopleIds_Reverse=arr2[1]+","+arr2[0];
					}else{
						eveningPeopleIds_Reverse=arr2[0];
					}
				}
				if($.trim(tempdataSource[editIndexDutyVal].eveningPeopleIds)==$.trim(eveningPeopleIds)
						||$.trim(tempdataSource[editIndexDutyVal].eveningPeopleIds)==$.trim(eveningPeopleIds_Reverse)){
					$('#mygrid').datagrid('getRows')[editIndexDutyVal]['eveningPeopleNames'] = eveningPeopleNames;
				}else{
					$('#mygrid').datagrid('getRows')[editIndexDutyVal]['eveningPeopleNames'] = 
						"<font color=\"#0033cc\" style=\"font-style:italic;font-weight:bold;\">"+eveningPeopleNames+"</font>";
				}
				//领导
				var ed3 = $('#mygrid').datagrid('getEditor', {index:editIndexDutyVal,field:'leaderIds'});
				var leaderNames = $(ed3.target).combobox('getText');
				var leaderIds = $(ed3.target).combobox('getValues');//此处不用getValue,因为multiple:true
				var arr3=leaderIds.toString().split(",");
				var leaderIds_Reverse="";
				if(arr3.length>2){
					 $.messager.alert('系统提示','<font size=\"2\" color=\"#666666\"><strong>带班领导最多可以选择2个!</strong></font>','warningSunnyIcon');
				return false;	
				}else{
					//1,2和2,1一致没有修改
					if(arr3.length==2){
						leaderIds_Reverse=arr3[1]+","+arr3[0];
					}else{
						leaderIds_Reverse=arr3[0];
					}
				}
				if($.trim(tempdataSource[editIndexDutyVal].leaderIds)==$.trim(leaderIds)
						||$.trim(tempdataSource[editIndexDutyVal].leaderIds)==$.trim(leaderIds_Reverse)){
					$('#mygrid').datagrid('getRows')[editIndexDutyVal]['leaderNames'] = leaderNames;
				}else{
					$('#mygrid').datagrid('getRows')[editIndexDutyVal]['leaderNames'] = 
						"<font color=\"#0033cc\" style=\"font-style:italic;font-weight:bold;\">"+leaderNames+"</font>";
				}
				//
				$('#mygrid').datagrid('endEdit', editIndexDutyVal);//结束上一行的编辑状态
				editIndexDutyVal = undefined;//重新赋值undefined
				return true;
			} else {
				return false;
			}
		}

你可能感兴趣的:(easyui datagrid rowedit点击编辑行)