Good afternoon,
I have a dashboard that groups results and applies a sum to one column and an average to another column. Here you can see the average being applied to the efficency percentage. While the calculation is correct, I would like to see the results in the same decimal format as my data. Is that possible?
In this example, I want the average to be 24.67% instead of .25
I canât seem to get it. The codes doesnât return any errors, but it isnât changing the average into a %. Maybe there is still a timing issue going on? Hereâs my version of your code:
// **************************************************
// Custom code for MainController
// Created: 7/12/2022 8:33:51 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Ice.BO;
using Ice.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Infragistics.Win.UltraWinGrid;
public class Script
{
EpiUltraGrid myGrd;
SummarySettings summarySettings;
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
private EpiDataView edvV_EarnedHours_1View;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvV_EarnedHours_1View = ((EpiDataView)(this.oTrans.EpiDataViews["V_EarnedHours_1View"]));
this.edvV_EarnedHours_1View.EpiViewNotification += new EpiViewNotification(this.edvV_EarnedHours_1View_EpiViewNotification);
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// End Wizard Added Custom Method Calls
myGrd = (EpiUltraGrid)csm.GetNativeControlReference("ed78aa51-6f56-4645-81cb-4e74292f54bb");
var QtyCol = myGrd.DisplayLayout.Bands[0].Columns["Calculated_EmpEff"];
summarySettings = myGrd.DisplayLayout.Bands[0].Summaries.Add("Avg", SummaryType.Average,QtyCol);
summarySettings.DisplayFormat = "{0:P1}";
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.edvV_EarnedHours_1View.EpiViewNotification -= new EpiViewNotification(this.edvV_EarnedHours_1View_EpiViewNotification);
this.edvV_EarnedHours_1View = null;
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void edvV_EarnedHours_1View_EpiViewNotification(EpiDataView view, EpiNotifyArgs args)
{
// ** Argument Properties and Uses **
// view.dataView[args.Row]["FieldName"]
// args.Row, args.Column, args.Sender, args.NotifyType
// NotifyType.Initialize, NotifyType.AddRow, NotifyType.DeleteRow, NotifyType.InitLastView, NotifyType.InitAndResetTreeNodes
if ((args.NotifyType == EpiTransaction.NotifyType.Initialize))
{
if ((args.Row > -1))
{
summarySettings.DisplayFormat = "{0:P1}";
}
}
}
}
OK Iâm on it. I can use the summarySettings to change other things about the summary row, like position above and below. But changing the format seems to be stuck. Thanks for the guidance!
Do you always have to close epicor after debugging in VS? I always get the message to restart epicor to allow VS to debug again. Even though VS is closed. Just an annoying quirk?
Thank you! I keep trying different DisplayFormats. Infragistics shows this for an average:
avgSummary.DisplayFormat = "Avg = {0:#####.00}";
I also tried your format. As well as a few other even simpler formats. I also added the % sign into the format in various way.
None of these changes seem to make any difference to the way the average is displayed. I donât see any strange timing issues. The EpiViewNotification fires twice. Once when the form loads, without any data so Row = -1. Then it fires again after I have entered my parameters, and the data gets loaded.
Quite a strange behavior!
Weird! Mine doesnât do that. It just stays as the regular old decimal. Debugging seems to show that the display format gets set as you described. But, if I refresh the form and look at the display format value it has reset itself to âAverage = {0:############.00}â.