AfterFieldChange Event on Second Native Grid

Good afternoon,
I have a dashboard made up of 2 BAQs. I am customizing the dashboard to add buttons, labels, and other controls to a blank tracker view.
I want to use the event: AfterFieldChange. However only three tables are listed as sources for this change, BpmData, Client, and Results. Results contains only the fields from the first BAQ, and none from the second BAQ. Can I refer to the second BAQ fields even though they are not listed in the results table?

The dashboard I am creating presents two grids (the two BAQs). There are two labels in the tracker view to hold the temporary totals. The idea is that the user checks off a list of rows from one grid, and the dashboard keeps a running total. There is a label to hold the temporary total for each grid. Each BAQ has an updatable bit field I am using as a flag. In the first BAQ grid, I can use this code to check for and utilize the flag field.

	private void Results_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{
		switch (args.Column.ColumnName)
		{
			case "Calculated_SalesShipFlag":
				if(args.Row["Calculated_SalesShipFlag"].ToString() == "True")
				{
					//MessageBox.Show("True");
					MySelectedValue = MySelectedValue + Convert.ToDecimal(args.Row["Calculated_RemainValue"]);	
					epiLabelSelectedValue.Text = Decimal.Parse(MySelectedValue.ToString()).ToString("c");
				}
				else
				{
					//MessageBox.Show("False");
					MySelectedValue = MySelectedValue - Convert.ToDecimal(args.Row["Calculated_RemainValue"]);	
					epiLabelSelectedValue.Text = Decimal.Parse(MySelectedValue.ToString()).ToString("c");	
				}
			break;

I want to do the same thing using a new variable and calculated label. I tried adjusting the case select statement to include the value for the checkbox from the second BAQ, but it doesn’t seem to care. Like this:

			case "Calculated_SalesShipFlagJobs":
				if(args.Row["Calculated_SalesShipFlagJobs"].ToString() == "True")
				{
					MessageBox.Show("True");
					MySelectedJobValue = MySelectedJobValue + Convert.ToDecimal(args.Row["Calculated_RemainValue"]);	
					epiLabelLinkedValue.Text = Decimal.Parse(MySelectedJobValue.ToString()).ToString("c");
				}
				else
				{
					MessageBox.Show("False");
					MySelectedJobValue = MySelectedJobValue - Convert.ToDecimal(args.Row["Calculated_RemainValue"]);	
					epiLabelLinkedValue.Text = Decimal.Parse(MySelectedJobValue.ToString()).ToString("c");	
				}
				break;

How can I implement this same kind of case select logic on the other native BAQ grid in my dashboard? Can I do this same thing with EpiViewNotification events? I couldn’t figure it out that way.

Open to any suggestions.
Thanks!
Nate

I am trying to create the event manually by copying the Results column changed syntax, but using the other view. This isn’t working for me.

	public void InitializeCustomCode()
	{
this.edvV_SalesPlanDash_Orders_1View_Column.ColumnChanged += DataColumnChangeEventHandler(this.edvV_SalesPlanDash_Orders_1View_AfterFieldChange);
}

public void DestroyCustomCode()
	{
	this.edvV_SalesPlanDash_Orders_1View_Column.ColumnChanged -= new DataColumnChangeEventHandler(this.edvV_SalesPlanDash_Orders_1View_AfterFieldChange);
}

This won’t compile, saying:
“‘Script’ does not contain a definition for ‘edvV_SalesPlanDash_Orders_1View_Column’ and no extension method ‘edvV_SalesPlanDash_Orders_1View_Column’ accepting a first argument of type ‘Script’ could be found (are you missing a using directive or an assembly reference?)”

If My dashboard has two BAQs, one in each native grid, and BAQ 1 gets assigned to Results, what does BAQ 2 get assigned to?
Thanks!
Nate

I tried another method of creating the event. I figure that I have to map the datasource from BAQ2 to a datatable that I can create the event on. This compiles:

public class Script
{
	public decimal MySelectedValue;
	public decimal MyLinkedValue;
	public EpiUltraGrid SPJobsGrid;
	public DataTable JobsGrid;

	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **


	private EpiDataView edvV_SalesPlanDash_Jobs_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.Results_Column.ColumnChanged += new DataColumnChangeEventHandler(this.Results_AfterFieldChange);
		this.edvV_SalesPlanDash_Jobs_1View = ((EpiDataView)(this.oTrans.EpiDataViews["V_SalesPlanDash_Jobs_1View"]));
		this.JobsGrid.ColumnChanged += new DataColumnChangeEventHandler(this.JobsGrid_AfterFieldChange);
		this.edvV_SalesPlanDash_Jobs_1View.EpiViewNotification += new EpiViewNotification(this.edvV_SalesPlanDash_Jobs_1View_EpiViewNotification);
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls


		// End Wizard Added Custom Method Calls
	}

	public void DestroyCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
		// Begin Wizard Added Object Disposal
		this.Results_Column.ColumnChanged -= new DataColumnChangeEventHandler(this.Results_AfterFieldChange);
		this.JobsGrid.ColumnChanged -= new DataColumnChangeEventHandler(this.JobsGrid_AfterFieldChange);
		this.edvV_SalesPlanDash_Jobs_1View = null;
		this.edvV_SalesPlanDash_Jobs_1View.EpiViewNotification -= new EpiViewNotification(this.edvV_SalesPlanDash_Jobs_1View_EpiViewNotification);
		// End Wizard Added Object Disposal

		// Begin Custom Code Disposal

		// End Custom Code Disposal
	}

	private void JobsGrid_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{	//BAQ2
		MessageBox.Show(args.ToString());
		switch (args.Column.ColumnName)
		{
			case "Calculated_SalesShipFlagJobs":
				if(args.Row["Calculated_SalesShipFlagJObs"].ToString() == "True")
				{
					//MessageBox.Show("True");
					MyLinkedValue = MyLinkedValue + Convert.ToDecimal(args.Row["Calculated_RemainValue"]);	
					epiLabelLinkedValue.Text = Decimal.Parse(epiLabelLinkedValue.ToString()).ToString("c");
				}
				else
				{
					//MessageBox.Show("False");
					MyLinkedValue = MyLinkedValue - Convert.ToDecimal(args.Row["Calculated_RemainValue"]);	
					epiLabelLinkedValue.Text = Decimal.Parse(epiLabelLinkedValue.ToString()).ToString("c");	
				}
			break;
		}
	}


	private void Results_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
	{ //BAQ1
		// ** Argument Properties and Uses **
		// args.Row["FieldName"]
		// args.Column, args.ProposedValue, args.Row
		// Add Event Handler Code
		switch (args.Column.ColumnName)
		{
			case "Calculated_SalesShipFlag":
				if(args.Row["Calculated_SalesShipFlag"].ToString() == "True")
				{
					//MessageBox.Show("True");
					MySelectedValue = MySelectedValue + Convert.ToDecimal(args.Row["Calculated_RemainValue"]);	
					epiLabelSelectedValue.Text = Decimal.Parse(MySelectedValue.ToString()).ToString("c");
				}
				else
				{
					//MessageBox.Show("False");
					MySelectedValue = MySelectedValue - Convert.ToDecimal(args.Row["Calculated_RemainValue"]);	
					epiLabelSelectedValue.Text = Decimal.Parse(MySelectedValue.ToString()).ToString("c");	
				}
			break;
		}
	}



	private void edvV_SalesPlanDash_Jobs_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))
		{
			SPJobsGrid = (Ice.Lib.Framework.EpiUltraGrid)csm.GetNativeControlReference("f02464c4-2adf-480b-89c9-7b0574f473dc");
			JobsGrid = (DataTable)SPJobsGrid.DataSource;
		}
	}
}

Here you can see that I setup a new datatable to hold the data from BAQ2. I create the table at the top under class Script. Then I assign the event in InitializeCustomCode. Then at the very bottom I pull the data from the ultragrid and use it to populate the new datatable I created.

Although this all compiles, it doesn’t fire the new event ever. Maybe there is an easier way? I want to present the user with a list of data that they can choose multiple from. As they choose each new row of data, the value should get added to the running total. So the user will look at a list of all the open jobs, and be able to select a subset of those jobs to observe the total open value on those selected jobs.

What would you do?

I ended up just splitting the dashboards into two. I couldn’t figure out how to make an event on that second grid. But this approach works just as well.