void gridJQFactorItems_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e) { try { GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem; JQManager jqm = new JQManager(); switch (e.DetailTableView.Name) { case "RatingScale": { long ratingScaleID = (long)dataItem.GetDataKeyValue("RatingScaleID"); // pull rating scale from cached version JQRatingScaleCollection cachedScaleList = LookupWrapper.GetJQRatingScale(false); JQRatingScale ratingScale = cachedScaleList.Find(ratingScaleID); JQRatingScaleCollection newScaleList = new JQRatingScaleCollection(); if (ratingScale != null) { // account for blank/null instructions ratingScale.RatingScaleInstruction = string.IsNullOrWhiteSpace(ratingScale.RatingScaleInstruction) ? GetLocalResourceObject("MissingInstructionsText").ToString() : ratingScale.RatingScaleInstruction; newScaleList.Add(ratingScale); } e.DetailTableView.DataSource = newScaleList; break; } case "RatingScaleResponses": { long ratingScaleID = (long)dataItem.GetDataKeyValue("RatingScaleID"); RatingScaleResponseCollection responseItemList = this.RatingScaleResponses.FindByScale(ratingScaleID); if (responseItemList.Count == 0) { RatingScaleResponseCollection listResponses = jqm.GetJQRatingScaleResponseCollectionByFactorItemID(ratingScaleID); this.RatingScaleResponses.AddRange(listResponses); responseItemList = listResponses; } e.DetailTableView.DataSource = responseItemList; break; } } } catch (Exception ex) { base.HandleException(ex); } }
void gridJQFactorItems_RowDrop(object sender, GridDragDropEventArgs e) { try { // make sure items are not null AND that the source table is equal to the destination table if ((e.DestDataItem != null && e.DraggedItems != null) && (string.Compare(e.DraggedItems[0].OwnerTableView.Name, e.DestDataItem.OwnerTableView.Name, true) == 0)) { switch (e.DestDataItem.OwnerTableView.Name) { case "FactorItems": long sourceFactorItemID = (long)e.DraggedItems[0].GetDataKeyValue("JQFactorItemID"); long destinationFactorItemID = (long)e.DestDataItem.GetDataKeyValue("JQFactorItemID"); long factorID = (long)e.DestDataItem.GetDataKeyValue("JQFactorID"); JQFactorItemCollection workFactorItems = this.FactorItems.FindByFactor(factorID); JQFactorItem sourceFactorItem = workFactorItems.Find(sourceFactorItemID); JQFactorItem destinationFactorItem = workFactorItems.Find(destinationFactorItemID); if (sourceFactorItem != null && destinationFactorItem != null) { int destinationIndex = workFactorItems.IndexOf(destinationFactorItem); destinationIndex = getNewIndex(ref destinationIndex, e); // remove and add in new position workFactorItems.Remove(sourceFactorItem); workFactorItems.Insert(destinationIndex, sourceFactorItem); // remove entire group this.FactorItems.RemoveByFactor(factorID); // now add back into batch with corrected order this.FactorItems.AddRange(workFactorItems); } bindData(this.FactorItems); //removing toggling of save order button because it was //enabled even when the ShowEditFields was returning false or when user was not an HR user //toggleButtons(true); break; case "RatingScaleResponses": long sourceJQResponseID = (long)e.DraggedItems[0].GetDataKeyValue("JQResponseID"); long destinationJQResponseID = (long)e.DestDataItem.GetDataKeyValue("JQResponseID"); long ratingScaleID = (long)e.DestDataItem.GetDataKeyValue("JQRatingScaleID"); RatingScaleResponseCollection workResponses = this.RatingScaleResponses.FindByScale(ratingScaleID); RatingScaleResponse sourceResponse = workResponses.Find(sourceJQResponseID); RatingScaleResponse destinationResponse = workResponses.Find(destinationJQResponseID); if (sourceResponse != null && destinationResponse != null) { int destinationIndex = workResponses.IndexOf(destinationResponse); destinationIndex = getNewIndex(ref destinationIndex, e); // remove and add in new position workResponses.Remove(sourceResponse); workResponses.Insert(destinationIndex, sourceResponse); // remove entire scale this.RatingScaleResponses.RemoveByScale(ratingScaleID); // now add back into batch with corrected order this.RatingScaleResponses.AddRange(workResponses); } e.DestDataItem.OwnerTableView.Rebind(); //removing toggling of save order button because it was //enabled even when the ShowEditFields was returning false or when user was not an HR user //toggleButtons(true); break; } } } catch (Exception ex) { base.HandleException(ex); } }