loadWorkFlowMultipleSelect=function(fieldId){
	$('#commonValidAlert').remove();
	$(".slick-cell.active").removeClass("redAlert");
	var moduleId = $("#moduleId").val();
	var projectId=$("#projectId").val();
	var grid =$('#listingGrid').data("gridInstance1");
	var row = grid.getActiveCell().row;
	var cell = grid.getActiveCell().cell;
	var workGroupId=grid.getData()[row].workgroupId;
	var moduleId = $("#moduleId").val();
	var projectId=$("#projectId").val();
	var serviceIds="";
	var serviceSelecteddata=grid.getData()[row].serviceNames;
        var serviceSelectedIds=grid.getData()[row].serviceIds;
        if(serviceSelectedIds==undefined){
        	serviceSelectedIds=grid.getData()[row].serviceNames
        }
	var subCategorySelecteddata=grid.getData()[row].subCategory;
        var subCategorySelectedIds=grid.getData()[row].subcategoryIds;
	var roleSelecteddata=grid.getData()[row].group;
	var $input;
	if(fieldId =="serviceNames"){
		$.ajax({
			url: "getParentServicesList.do",
			type: "POST",
			dataType: 'json',
			async: false,
			data:"projectId="+projectId,
			success:function(result){
				$input=$("#"+fieldId);
				$input.empty();
				$(".select2-results__options").empty();
				$.each(result, function(key, value){
					var selected = "";
					if((","+serviceSelecteddata+",").indexOf(value.serviceName) != -1){
						selected = "selected";
					}
					$input.append("<option value='"+value.serviceId+"'"+selected+">"+value.serviceName+"</option>");
					serviceIds += value.serviceId;
				});
			}
		});
	}
	else if(fieldId =="subCategory"){
		$.ajax({
			url: "getSubCategories.do",
			type: "POST",
			dataType: 'json',
			async: false,
			data:"projectId="+ projectId +"&serviceIds="+serviceSelectedIds,
			success:function(result){
				$input=$("#"+fieldId);
				$input.empty();
				$(".select2-results__options").empty();
				$input.append("<option id='all' value='All'>All</option>");
				$.each(result, function(key, value){
					var optGroup = $("<optgroup label='" + value.categoryLabel + "'>");
					$.each(value.options, function (key1, value1) {
						var selected = "";
						if((","+subCategorySelecteddata+",").indexOf(value1.subCategoryName) != -1){
							selected = "selected";
						}
						optGroup.append("<option value='" + value1.subCategoryID + "'"+selected+">" + value1.subCategoryName + "</option>");
					});
					$input.append(optGroup);
				});
			}
		});
	}
	else if(fieldId =="group"){
		$.ajax({
			url: "getRoleList.do",
			type: "POST",
			dataType: 'json',
			async: false,
			data:"projectId="+projectId,
			success:function(result){
				$input=$("#"+fieldId);
				$input.empty();
				$(".select2-results__options").empty();
				$.each(result, function(key, value){
					var selected = "";
					if((","+roleSelecteddata+",").indexOf(value.roleName) != -1){
						selected = "selected";
					}
					$input.append("<option value='"+value.roleId+"'"+selected+">"+value.roleName+"</option>");
				});
			}
		});
	}
}
loadStateSelectCell=function(fieldId){
	$('#commonValidAlert').remove();
	$(".slick-cell.active").removeClass("redAlert");
	var moduleId = $("#moduleId").val();
	var projectId=$("#projectId").val();
	var grid =$('#listingGrid').data("gridInstance1");
	var row = grid.getActiveCell().row;
	var cell = grid.getActiveCell().cell;
	var $input;
	if(fieldId=="presentState"){
		var statesSelecteddata=grid.getData()[row].presentState;
	}else{
		var statesSelecteddata=grid.getData()[row].possibleState;
	}
	$.ajax({
		url: "getStateList.do",
		type: "POST",
		dataType: 'json',
		async: false,
		data:"projectId="+projectId,
		success:function(result){
			$input=$("#"+fieldId);
			$(".select2-results__options").empty();
			$.each(result, function(key, value){
				var selected = "";
				if((","+statesSelecteddata+",").indexOf(value.statesName) != -1 || (","+statesSelecteddata+",").indexOf(value.statesId) != -1){
					selected = "selected";
				}
				$input.append("<option value='"+value.statesId+"'"+selected+">"+value.statesName+"</option>");
			});
		}
	});
}
$(document).on("click",".showDerivedFieldsWorkflowPop",function(eve){
	if($("#commonValidAlert").is(":visible")==false){
		if(!$(eve.target).is(".showDerivedFieldsWorkflowPop .readMoreData")){
			var grid =$('#listingGrid').data("gridInstance1");
			var row = grid.getActiveCell().row;
			var cell = grid.getActiveCell().cell;
			var workflowId=grid.getData()[row].workflowId;
			var moduleId = $("#moduleId").val();
			var projectId=$("#projectId").val();
			$(".showDerivedFieldsWorkflowPop").removeClass("opened");
			$(this).addClass("opened");
			$.ajax({
				url: "getWorkflowDerivedFields.do",
				type: "POST",
				dataType: 'json',
				async: false,
				data:"projectId="+projectId+"&workflowId="+workflowId,
				success:function(result){
					var derivedField1Select = $("#derivedField1");
					var derivedField2Select = $("#derivedField2");
					var derivedField3Select = $("#derivedField3");

					derivedField1Select.empty();
					derivedField2Select.empty();
					derivedField3Select.empty();

					$.each(result[0].derivedFld1, function(index, item) {
						if (result[0].derivedFld1SelectedId.includes(item.derivedFld1Name)){
							derivedField1Select.append("<option id="+item.derivedFld1ID+" selected value='"+item.derivedFld1ID+"'>"+item.derivedFld1Name+"</option>");
						}else{
							derivedField1Select.append("<option id="+item.derivedFld1ID+" value='"+item.derivedFld1ID+"'>"+item.derivedFld1Name+"</option>");
						}
					});

					$.each(result[0].derivedFld2, function(index, item) {
						if (result[0].derivedFld2SelectedId.includes(item.derivedFld2Name)){
							derivedField2Select.append("<option id="+item.derivedFld2ID+" selected value='"+item.derivedFld2ID+"'>"+item.derivedFld2Name+"</option>");
						}else{
							derivedField2Select.append("<option id="+item.derivedFld2ID+" value='"+item.derivedFld2ID+"'>"+item.derivedFld2Name+"</option>");
						}
					});

					$.each(result[0].derivedFld3, function(index, item) {
						if (result[0].derivedFld3SelectedId.includes(item.derivedFld3Name)){
							derivedField3Select.append("<option id="+item.derivedFld3ID+" selected value='"+item.derivedFld3ID+"'>"+item.derivedFld3Name+"</option>");
						}else{
							derivedField3Select.append("<option id="+item.derivedFld3ID+" value='"+item.derivedFld3ID+"'>"+item.derivedFld3Name+"</option>");
						}
					});
					$("#derivedField1, #derivedField2, #derivedField3").multipleSelect('refresh');

					if(result[0].considerCheckBox=="-1"){
						$("#considerCheckBox").prop("checked", false);
					}else {
						$("#considerCheckBox").prop("checked", true);
					}

				},complete:function(){
					if($(".showDerivedFieldsWorkflowPop.opened").position() && $(".showDerivedFieldsWorkflowPop.opened").position()!==undefined) {
					var pos=$(".showDerivedFieldsWorkflowPop.opened").position().left;
					$(".slick-viewport.slick-viewport-top.slick-viewport-right").scrollLeft(pos);
					$(".derivedFieldsDetails").show();
					$(".derivedFieldsDetails").position({
						my: "left top",
						at: "left top+30",
						of: ".showDerivedFieldsWorkflowPop.opened",
						collision: "none"
					});
					if($("#considerCheckBox").prop("checked")==false){
						$("#derivedField1,#derivedField2,#derivedField3").multipleSelect("disable");
					}else{
						$("#derivedField1,#derivedField2,#derivedField3").multipleSelect("enable");
					}
				}
				}
			});
		}
	}
});
$(document).on("click","#closeDerivedFields,#cancelDerivedFlds",function(){
	$(".showDerivedFieldsWorkflowPop").removeClass("opened active");
});
$(document).on("change","#considerCheckBox",function(){
	if($(this).prop("checked")==false){
		$("#derivedField1,#derivedField2,#derivedField3").multipleSelect("disable");
	}else{
		$("#derivedField1,#derivedField2,#derivedField3").multipleSelect("enable");
	}
});
$(document).on("click","#saveWCDerivedFlds",function(){
	var df1=[];
	var df2=[];
	var df3=[];
	var urlParameters;
	var grid =$('#listingGrid').data("gridInstance1");
	var row = grid.getActiveCell().row;
	var cell = grid.getActiveCell().cell;
	var workflowId=grid.getData()[row].workflowId;
	var moduleId = $("#moduleId").val();
	var pageNo=$("#listingGridPager").attr("data-pageno");
	var pageSize=$(".gridViewPort .recordLimit").val()
	var projectId=$("#projectId").val();
	if($("#considerCheckBox").prop("checked")==true && $("#derivedField1").val()=="" && $("#derivedField2").val()=="" && $("#derivedField3").val()==""){
		$("#derivedField1 + .ms-parent").after("<p class='fldErr' id='dfFldErr' style='bottom: 35px;'>Please choose derived fields</p>");
		return false;
	}
	if($("#considerCheckBox").prop("checked")==true){
		df1=$("#derivedField1").multipleSelect('getSelects');
		df2=$("#derivedField2").multipleSelect('getSelects');
		df3=$("#derivedField3").multipleSelect('getSelects');
		urlParameters="derivedfld1="+df1+"&derivedfld2="+df2+"&derivedfld3="+df3;
	}else{
		urlParameters="derivedFlds="+0;
	}
	$.ajax({
		url: "saveWorkflowDerivedFields.do",
		type: "POST",
		dataType: 'json',
		async: false,
		data:"projectId="+projectId+"&workflowId="+workflowId+"&"+urlParameters,
		success:function(result){

		},complete:function(){
			$(".showDerivedFieldsWorkflowPop.opened span").text("Derived Field 1:"+df1+" Derived Field 2:"+df2+"Derived Field 3:"+df3);
			$("#closeDerivedFields").click();
		}
	});
	loadSdGridData(projectId, moduleId, pageNo, pageSize);
});
$(document).on("click",function(e){
	if(!$(e.target).is("#dfFldErr,#dfFldErr *")){
		$("#dfFldErr").remove();
	}
});
$(document).on("click",".readMoreData",function(e) {
	if($(this).hasClass("opened")==true){
		$("#readMoreBlk").hide();
		$(this).removeClass("opened");
	}else {
		$(".readMoreData").removeClass("opened");
		$(this).addClass("opened");
		var pos=$(".showDerivedFieldsWorkflowPop.active").position().left;
		$(".slick-viewport.slick-viewport-top.slick-viewport-right").scrollLeft(pos);
		var moreData = $(this).prev("#decr").html();
		$("#readMoreBlk .loadedData").empty().append(moreData);
		$("#readMoreBlk").show();
		$("#readMoreBlk").position({
			my: "center+30 top",
			at: "left top+20",
			of: ".readMoreData.opened",
			collision: "none"
		});
	}
});
var gridReload=true;
saveWorkFlowDetails = function (workflowId, field, projectId, dataToSave){
	$('#commonValidAlert').remove();
	var urlParameters;
	$(".slick-cell.active").removeClass("redAlert");
	var pageNumber=$("#listingGridPager").attr("data-pageno");
	var pageSize=$(".gridViewPort .recordLimit").val()
	var moduleId = $("#moduleId").val();
	if(workflowId == undefined){
		workflowId = 0;
		if(dataToSave.presentState== null ||dataToSave.presentState==""){
			cell=5;
			field="present state";
			checkIsSelected(field,"",cell);
			return;
		}else if(dataToSave.possibleState== null || dataToSave.possibleState==""){
			cell=6;
			field="possible state";
			checkIsSelected(field,"",cell);
			return;
		}else if(dataToSave.serviceNames==null || dataToSave.serviceNames=="" || dataToSave.serviceNames[0]==""){
			cell=1;
			field="Service";
			checkIsSelected(field,"",cell);
			return;
		}else if(dataToSave.subCategory==null || dataToSave.subCategory==""){
			cell=2;
			field="Sub Category";
			checkIsSelected(field,"",cell);
			return;
		}else if( dataToSave.group== null || dataToSave.group==""){
			cell=4;
			field="Group";
			checkIsSelected(field,"",cell);
			return;
		}else{
			urlParameters="parameterType="+field+"&"+field+"=" + dataToSave[field]+"&possibleState="+dataToSave.possibleState +"&presentState="+dataToSave.presentState+"&serviceNames="+dataToSave.serviceNames+"&subCategory="+dataToSave.subCategory;
		}


	}else{
		checkIsSelected(field,dataToSave[0]);
		if(field =="presentState"){
			if(dataToSave.presentState== null){
				cell=5;
				field="present-state";
				checkIsSelected(field,"",cell);
				return;
			}else if(dataToSave.possibleState== null || dataToSave.possibleState==undefined){
				cell=6;
				field="possible-state";
				checkIsSelected(field,"",cell);
				return;
			}else{
				urlParameters="parameterType="+field+"&"+field+"=" + dataToSave[field]+"&possibleState="+dataToSave.possibleState;
			}
		}else if(field =="possibleState"){
			if(dataToSave.presentState== null){
				cell=5;
				field="present-state";
				checkIsSelected(field,"",cell);
				return;
			}else if(dataToSave.possibleState== null || dataToSave.possibleState==undefined){
				cell=6;
				field="possible-state";
				checkIsSelected(field,"",cell);
				return;
			}else{
				urlParameters="parameterType="+field+"&"+field+"=" + dataToSave[field]+"&presentState="+dataToSave.presentState;
			}
		}else if(field =="serviceNames"){
			if(dataToSave.serviceNames.length == 0){
				cell=1;
				field="Service";
				checkIsSelected(field,"",cell);
				return;
			}else{
				urlParameters= "parameterType="+field+"&serviceNames=" + dataToSave.serviceNames;
			}
		}else if(field =="subCategory"){
			if(dataToSave.subCategory.length == 0){
				cell=2;
				field="Sub Category";
				checkIsSelected(field,"",cell);
				return;
			}else{
				urlParameters= "parameterType="+field+"&subCategory=" + dataToSave.subCategory;
			}
		}else if(field =="group"){
			if(dataToSave.group.length == 0){
				cell=4;
				field="Group";
				checkIsSelected(field,"",cell);
				return;
			}else{
				urlParameters= "parameterType="+field+"&group=" + dataToSave.group;
			}
		}
	}
	var abc;
	gridReload=true;
	$.ajax({
		url: "saveWorkflowConfigDetails.do",
		type: "POST",
		async: false,
		data: "projectId=" + projectId + "&workflowId="+workflowId + "&" + urlParameters,
		success: function (result) {
			abc=result;

		},complete:function(){
			var grid =$('#listingGrid').data("gridInstance1");
			var row = grid.getActiveCell().row;
			var data=grid.getDataItem(row);
			//grid.gotoCell(row, cell, true);
			if(abc ==3){
				if(field="possibleState"){
					cell=6;
					field="Possible_State";
				}else if(field="presentState"){
					cell=5;
					field="Present_State";
				}
				checkIsSelected(field,"",cell);
			}


		}
	});
	if(gridReload==true){
		loadSdGridData(projectId, moduleId, pageNumber, pageSize);
	}
}
checkIsSelected=function(field,dataToSave,cell){
	var grid =$('#listingGrid').data("gridInstance1");
	var row = grid.getActiveCell().row;
	if(cell==undefined){
		cell = grid.getActiveCell().cell;
	}
	if(dataToSave==""){
		grid.gotoCell(row, cell, true);
		$(".slick-cell.active  .select2-container").addClass("redAlert");
		if(field=="serviceNames"){
			$('#WorkflowGridBlock').append('<p id="commonValidAlert" class="fldErr"><span class="topCurve"></span>Atleast one Service must be selected<a href="javascript:void(0)" id="cancelNewRow" class="cancelNewRow">Cancel</a></p>');
		}else if(field=="present state" || field=="possible state"){
			$('#WorkflowGridBlock').append('<p id="commonValidAlert" class="fldErr"><span class="topCurve"></span>Select '+field+'</p>');
		}
		else if(field=="Service" && $('#WorkflowGridBlock').is(":visible")==true){
			$('#WorkflowGridBlock').append('<p id="commonValidAlert" class="fldErr"><span class="topCurve"></span>Select '+field+'</p>');
		}else if(field=="Sub Category Name" || field=="Service" || field=="Category"){
			$('#SubCategoryGridBlock').append('<p id="commonValidAlert" class="fldErr"><span class="topCurve"></span>Select '+field+'</p>');
			gridReload=false;
		}else if(field=="service" || field=="category"){
			$('#SubCategoryGridBlock').append('<p id="commonValidAlert" class="fldErr"><span class="topCurve"></span>Atleast one '+field+' must be selected</p>');
			gridReload=false;
		}
		else if(field=="Sub Category" || field=="Group"){
			$('#WorkflowGridBlock').append('<p id="commonValidAlert" class="fldErr"><span class="topCurve"></span>Atleast one '+field+' must be selected</p>');
		}
		$('#commonValidAlert').position({my: "left top",at: "left top+30",of: ".redAlert",collision: "none"});
		$('#commonValidAlert').show();
		return false;
	}
}
$(document).on("click",".workflowViewer",function(){
	var projectId=$("#projectId").val();
	$(".gridViewPort--main").hide();
	$(".workFlowViewerBlock").show();
	var statesData;
	var statesIdsData;
	$.ajax({
		url: 'getWorkFlow_States.do',
		type: "POST",
		data: "projectId="+projectId,
		async: false,
		success: function(data) {
			statesIdsData=data;

		},
		complete: function() {
			$.ajax({
				url: 'getWorkflowStateList.do',
				type: "POST",
				data: "projectId="+projectId,
				async: false,
				success: function(data) {
					statesData=data;

				}
			});
		}
	});

// Create a new directed graph
	$flowChartBlk=$("#WorkFlowViewChartBlk");
	$graphObject = new dagreD3.graphlib.Graph().setGraph({});
	$render = dagreD3.render();
	var g = $graphObject;

// Automatically label each of the nodes
	$.each(statesData, function(index, key) {
		if(key.stateName === "new" || key.stateName === "New"){
			g.setNode(key.stateId, {label: key.stateName, style:"fill:"+key.stateColor,shape: "ellipse"});
		}else if(key.stateName === "Assign" || key.stateName === "assign"){
			g.setNode(key.stateId, {label: key.stateName, style:"fill:"+key.stateColor,shape: "ellipse"});
		}else if(key.stateName === "Close" || key.stateName === "close"){
			g.setNode(key.stateId, {label: key.stateName, style:"fill:"+key.stateColor,shape: "ellipse"});
		}else{
			g.setNode(key.stateId, {label: key.stateName, style:"fill:"+key.stateColor});
		}
	});
// Set up the edges
	var arrData = [];
	var i = 0;
	$.each(statesIdsData, function (key, connectedStates) {
		arrData.push({ key: key, connectedStates: connectedStates });
	});

	arrData.forEach(function (data) {
		var key = data.key;
		var connectedStates = data.connectedStates;
		connectedStates.forEach(function (connectedState) {
			g.setEdge("" + key, "" + connectedState, { label: " ", lineInterpolate: 'basis' });
		});
	});
// Set some general styles
	g.nodes().forEach(function(v) {
		var node = g.node(v);
		node.rx = node.ry = 5;
		
	});
// Add some custom colors based on state
	var svg = d3.select($flowChartBlk.find("svg").get(0)),
		inner = svg.select("g");
	svg.attr('width', "1024");
// Set up zoom support
	var zoom = d3.behavior.zoom().on("zoom", function() {
		inner.attr("transform", "translate(" + d3.event.translate + ")" +
			"scale(" + d3.event.scale + ")");
	});
	svg.call(zoom);

// Create the renderer
	var render = $render;

// Run the renderer. This is what draws the final graph.
	render(inner, g);

// Center the graph
	var initialScale =1;
	zoom.translate([((svg.attr("width") - g.graph().width * initialScale) / 2) + 60, 20]).scale(initialScale).event(svg);
	svg.attr('width', "90%");
	svg.attr('height', g.graph().height * initialScale + 40);

	var g;
	// Set margins, if not present
	if (!g.graph().hasOwnProperty("marginx") &&
		!g.graph().hasOwnProperty("marginy")) {
		g.graph().marginx = 2;
		g.graph().marginy = 2;
	}
	g.graph().transition = function(selection) {
		return selection.transition().duration(500);
	};

	g.graph().transition = function(selection) {
		return selection.transition().duration(500);
	};

	// Render the graph into svg g
	d3.select($flowChartBlk.children("svg g").get(0)).call(render, g);
});
$(document).on("click",".workFlowViewerBlock .backBtn",function(){
	$(".workFlowViewerBlock").hide();
});
var collapseDataSetObject = {};
var historyId;

$(document).on("click", "#WorkflowGridBlock .expandDerivedFields", function (e)
{
	var isGridWithCollapse=false;
	$("#cancelDerivedFlds").click();
	var projectId = $(this).attr("data-projectId");
	var slickGrid = $("#listingGrid").data("gridInstance1");
	var dynamicAttributes = ["workflowId", "workGroupName", "serviceNames", "subCategory", "derivedFields","group","presentState","possibleState"];
	var row=$(".slick-row.active").index();
	var dataToSave=slickGrid.getData(row);
	var grid =$('#listingGrid').data("gridInstance1");
	var row = grid.getActiveCell().row;
	var cell = grid.getActiveCell().cell;
	var workflowId=grid.getData()[row].workflowId;
	$.ajax({
		url: "getWorkflowExpandDerivedFields.do",
		type: "POST",
		dataType: 'json',
		async: false,
		data:"workflowId=" + workflowId,
		success:function(result){
			var data = slickGrid.getData();
			for (var j=data.length-1; j>=0; j--){
				if(data[j].workflowId==""){
					isGridWithCollapse=true;
					data = data.filter(function(elem){
						slickGrid.invalidateRow(j);
						row=$(".slick-row.active").index();
						return elem != data[j];
					})
				}
			}
			var newrow;
			var dataLength = data.length;
			var j=0;
			for (var i =result.length-1; i>=0; i--)
			{
				var indiData = result[i];
				indiData["id"] = "history" + (j + dataLength);
				indiData["historyId"] = "" + dataToSave.workflowId;
				newrow = jQuery.extend(dynamicAttributes, indiData);
				data.splice(row + 1, 0, indiData);
				j++;
			}
			slickGrid.setData(data);
			var totRows=data.length;
			var totHeight=(totRows+1)*30;
			$("#listingGrid").css("height",""+totHeight+"px");
			slickGrid.resizeCanvas();
		},complete:function(){
			var newRowEnd=row+4;
			for(i=row+2;i<=newRowEnd;i++){
				$(".slick-row:nth-child("+i+") .slick-cell").addClass("disabled expandedData");
				$(".slick-cell.expandedData.slick-cell-checkboxsel input[type=checkbox]").remove();
				$(".slick-cell.expandedData .expandDerivedFields").remove();
				$(".slick-cell.expandedData").removeClass("showDerivedFieldsWorkflowPop");
			}
			collapseDataSetObject["expandHistoryIco"+dataToSave.workflowId] = "collapseIco";
			if(isGridWithCollapse==true){
				row=row+1;
				$(".slick-row:nth-child("+row+")").find(".expandDerivedFields").addClass("collapseDerivedFields").removeClass("expandDerivedFields");
			}else{
				$(".slick-row.active").find(".expandDerivedFields").addClass("collapseDerivedFields").removeClass("expandDerivedFields");
			}
			$(".collapseDerivedFields").text("-");
			e.preventDefault();
		}
	});
});


$(document).on("click", "#WorkflowGridBlock .collapseDerivedFields", function (e)
{
	var isRowFound=-1;
	collapseDataSetObject["expandHistoryIco"+historyId] = "expandIco";
	var slickGrid = $("#listingGrid").data("gridInstance1");
	var data = slickGrid.getData();
	var dataLength = data.length;
	var row=$(".slick-row.active").index();
	var dataToSave=slickGrid.getData(row);
	var checkedRows = [];
	for (var i =row; i<dataLength ; i++)
	{
		var indiData = data[i];
		if (indiData.historyId!=undefined)
		{
			if(isRowFound==-1){
				isRowFound=i;
			}
			checkedRows.push(i);

		}
	}
	data.splice(isRowFound,3);
	for (var rowLength = 0; rowLength < checkedRows.length; rowLength++)
	{
		slickGrid.invalidateRow(checkedRows[rowLength]);
		slickGrid.setData(data);
		slickGrid.updateRowCount();
		var totRows=data.length;
		var totHeight=(totRows+1)*30;
		$("#listingGrid").css("height",""+totHeight+"px");
		slickGrid.resizeCanvas();
		slickGrid.render();
		dataLength = dataLength - 1;
		slickGrid.scrollRowIntoView(dataLength);
	}
	$(".slick-row.active").find(".collapseDerivedFields").addClass("expandDerivedFields").removeClass("collapseDerivedFields");
	$(".expandDerivedFields").text("+");
	e.preventDefault();
});
deleteWorkflow= function(checkboxValues, projectId){
	var pageNumber=$("#listingGridPager").attr("data-pageno");
	var pageSize=$(".gridViewPort .recordLimit").val()
	var moduleId = $("#moduleId").val();
	var projectId = $("#projectId").val();
	$.ajax({
		url: "deleteSdWorkflow.do",
		type: "POST",
		dataType: 'json',
		async: false,
		data: "workflowList=" + checkboxValues + "&projectId=" + projectId,
		success: function (result) {
		},
		complete:function(){
			$("#listingGrid").before('<div class="sucessMsg" style="display: none;" id="success"><i class="ico statusIco"></i><p>${I18N_OBJECT.tr("Deleted successfully")} </p></div>');
		}
	});
	loadSdGridData(projectId,moduleId,pageNumber,pageSize);
}
$(document).on("change","#listingGrid select#presentState",function(){
    var thisVal=$("#listingGrid #presentState option:selected").text()
    $("input[type=hidden]#presentStateValue").remove();
    $("body").append("<input type='hidden' value='"+thisVal+"' id='presentStateValue'>");
});
$(document).on("change","#listingGrid select#possibleState",function(){
     var thisVal=$("#listingGrid #possibleState option:selected").text()
    $("input[type=hidden]#possibleStateValue").remove();
    $("body").append("<input type='hidden' value='"+thisVal+"' id='possibleStateValue'>");
});
$(document).on("change","#listingGrid select#serviceNames",function(){
	var thisVal = $("#listingGrid #serviceNames option:selected").map(function() {
	    return $(this).text();
	}).get().join(" ");
    $("input[type=hidden]#serviceValue").remove();
    $("body").append("<input type='hidden' value='"+thisVal+"' id='serviceValue'>");
});
$(document).on("change","#listingGrid select#subCategory",function(){
     var thisVal = $("#listingGrid #subCategory option:selected").map(function() {
	    return $(this).text();
	}).get().join(" ");
    $("input[type=hidden]#subCategoryValue").remove();
    $("body").append("<input type='hidden' value='"+thisVal+"' id='subCategoryValue'>");
});