Grid Property Changed

I have a Grid that once populated from a Dynamic Query, I would like to have text boxes populated with the top record. I don’t want to use the foreach method because it runs through the rows in the grid.
I have an event on the grid of Property Changed. When this event occurs I want the text boxes to be populated with the row data. I have this so far but I am getting errors.

	{
		UltraGridRow activeRow = grid_MovementforOrder2.ActiveRow;
		dbMovementCreateDate.Text = activeRow.Cells["UD091_Date01"].Value.ToString();
		tbMovementCreateTime.Text = activeRow.Cells["Calculated_CreateTime"].Value.ToString();
		tbMovementFromDeptDesc.Text = activeRow.Cells["UDCodes_LongDesc"].Value.ToString();
		tbMovementFromDept.Text = activeRow.Cells["UD091_ShortChar03"].Value.ToString();
		tbMovementToDept.Text = activeRow.Cells["UD091_ShortChar04"].Value.ToString();
		tbMovementToDeptDesc.Text = activeRow.Cells["UDCodes1_LongDesc"].Value.ToString();
			//Hide Buttons if Order is not in 99
		{
			if (tbMovementToDept.ToString() == ("99"))
			{
			btnShipstore.Visible = true;
			btnCreateNon_Conformance.Visible = true;
			}
			else
			{
			btnShipstore.Visible = false;
			btnCreateNon_Conformance.Visible = false;
			}
		}
	}

I would add a check for if activeRow is not null

Also, change this

if (tbMovementToDept.ToString() == ("99"))

to this

if (tbMovementToDept.Text.ToString() == ("99"))

Okay, I did that and added some Message Boxes to see what is going on. See code below:

	private void grid_MovementforOrder2_PropertyChanged(object sender, Infragistics.Win.PropertyChangedEventArgs args)
	{
		UltraGridRow activeRow = grid_OrderMovement3.ActiveRow;
		MessageBox.Show("UltraGridRow ActiveRow");
		if (grid_OrderMovement3.ActiveRow != null)
		{
		MessageBox.Show("Not Null");
		dbMovementCreateDate.Text = activeRow.Cells["UD091_Date01"].Value.ToString();
		MessageBox.Show("1st Value Entered");
		tbMovementCreateTime.Text = activeRow.Cells["Calculated_CreateTime"].Value.ToString();
		tbMovementFromDeptDesc.Text = activeRow.Cells["UDCodes_LongDesc"].Value.ToString();
		tbMovementFromDept.Text = activeRow.Cells["UD091_ShortChar03"].Value.ToString();
		tbMovementToDept.Text = activeRow.Cells["UD091_ShortChar04"].Value.ToString();
		tbMovementToDeptDesc.Text = activeRow.Cells["UDCodes1_LongDesc"].Value.ToString();
			//Hide Buttons if Order is not in 99
		{
			if (tbMovementToDept.Text.ToString() == ("99"))
			{
			btnShipstore.Visible = true;
			btnCreateNon_Conformance.Visible = true;
			}
			else
			{
			btnShipstore.Visible = false;
			btnCreateNon_Conformance.Visible = false;
			}
		}
		}
		else
		{
			MessageBox.Show("Is Null");
		}
	}

I am getting these Message Boxes: UltraGridRow ActiveRow and Is Null. So that is telling me it is never seeing this row in the grid as active. Is there another way to call the grid results without actually having to click on the row. I need it to populate the text boxes once the grid is populated with the first row data.

Why don’t you bind the grid to a dataview and those textboxes to the same data view then you’ll get all the benefit of the EpiMagic and no custom code is needed…
Populate the Grid by using a BAQDataView then binding it to the Grid. Then Bind the TextBoxes to the same BAQDataView.
You can do publish and subscribe to automatically run through and or filter the BAQ automatically.

When in doubt #EpiMagic

2 Likes

That sounds amazing…and a little over my head…So I am already populating the grid with a dynamic query and BAQ. How would I say BAQ Data View instead?

	DynamicQueryAdapter dqa1 = new DynamicQueryAdapter(oTrans);
	dqa1.BOConnect();
	QueryExecutionDataSet qeds1 = dqa1.GetQueryExecutionParametersByID("GS_UD09_Movement_All");
	qeds1.ExecutionParameter.Clear();
	qeds1.ExecutionParameter.AddExecutionParameterRow("OrderNum", epiNumericOrderNumRef.Value.ToString() , "nvarchar", false, Guid.NewGuid(), "B");
	qeds1.ExecutionParameter.AddExecutionParameterRow("OrderLine", epiNumericEditorOrderLineNo.Value.ToString() , "nvarchar", false, Guid.NewGuid(), "B");
	dqa1.ExecuteByID("GS_UD09_Movement_All", qeds1);
	grid_MovementforOrder2.DataSource = dqa1.QueryResults.Tables["Results"];
	grid_OrderMovement3.DataSource = dqa1.QueryResults.Tables["Results"];

I know how to do the foreach method but I don’t want it to go through the entire grid. I want it to return the first row.

So the OrderNumber and th OrderLine is that coming from…? Order Entry? What form are you on so I can provide a bit better example.

I am on a customized Dashboard. This particular grid is using a BAQ I call. It uses the parameters of Order Number and Order line which come from and Order BAQ in my dashboard.

Got it, if you are already in a dashboard any reason why you can’t use a Publish Subscribe Grid / Tracker? In the Original Dashboard? That is reference your GS_UD09_Movement_All BAQ in your original dashboard and subscribe it to the Top Grid… so when the top grid changes… the bottom one does too… Requires no code…
(If I’m understanding correctly)

Yes, I could do that. However, I decided not to because I need to be able to place the tab/grid that it would create in a particular location. If I put it on the main dashboard I can’t move it to a different sheet…unless you would know how to do that…
So in order to have control of my layout I have resorted to Dynamic Queries that call my BAQ’s and I can put them in grids wherever I want.

Or if there is someway to hide the tab that the Grid/Tracker would create in the Dashboard?

ok… I mean you could still do it in a customization but fair enough. Then I suggest you use the BAQDataView method I’ll try to outline it below
Here is a video I made which does exactly this on a regular form not a doashboard but the same concept applies…

In your Case you’ll be publishing the original BAQ Columns OrderNum and OrderLine

Then subscribing your BAQDataView to these. If you watch the video I think you’ll get the gist of it… Here is the Post which explains further

You’ll have to remove the paramters from your GS_UD09_Movement_All and make sure that OrdereNum and OrderLine are in the BAQ Results, then the “filtering” will happen “magically”

Let me know if you run into issues and I’ll try to provide more detail.

PS: In my example above I’m only subscribing to one column, but to do two columns all you have to do is repeat the Publisher and the Subcribe… as follows (below I’m subscribing to changes to Year_c and or Type_c

void CreateBAQView() {
// create the baq view and add it to the transaction
bdvLeaveUsage = new BAQDataView("Payroll-Cust-LeaveUsage");
oTrans.Add("LeaveUsageView", bdvLeaveUsage);
 
// publish columns we'll bind to
var yearBinding = "UD100View.Year_c";
var typeBinding = "UD100View.Type_c";
 
oTrans.PublishColumnChange(yearBinding, Guid.NewGuid().ToString());
oTrans.PublishColumnChange(typeBinding, Guid.NewGuid().ToString());
var yearPub = oTrans.GetPublisher(yearBinding);
var typePub = oTrans.GetPublisher(typeBinding);
 
// subscribe our BAQ view
// NOTE: In E10 field names use the format with an underscore. will no longer work.
bdvLeaveUsage.SubscribeToPublisher(yearPub.PublishName, "Calculated_PayRollYear");
bdvLeaveUsage.SubscribeToPublisher(typePub.PublishName, "LaborDtl_IndirectCode");
 

}
3 Likes

That is amazing! So my only question would be…will this slow the load of the dashboard down since you load the view at initialize? Do you have to do it at initialize? I’m assuming you do because that is the only way to bind it to a grid. What is the benefit of a Dynamic Query vs. a BAQ View?

Also, on a side note…you are like the Go To guy here while we are implementing our Epicor lol. We have all watched your videos :):smiley:

It shouldn’t slow anything down since your are subscribing it to the top view, it will only run once there’s something to filter against.
and thanks glad I could help

Okay great. So I have a ton of Dynamic Queries running currently on a text box leave. Do you think it would be more beneficial to change those to BAQ DAta Views?

Also, do you ever do any consulting for people in the middle of Epicor Implementation? Not sure if that is okay to ask on here or not.

My motto is when you can use EpiMagic… do… you get a ton of benefits. So yes I think it would be beneficial. Ask @Chris_Conn I’m all about the EpiMagic… and I drilled it into his head… (note he still doesn’t listen… but I try)

I don’t do consulting these days, trying to stay out of the consulting world. If you’d like me to recommend some help I can certainly do that off the forum I know some good folks all over the place. Let me know and i’ll shoot you an email with some recommendations.

1 Like

These are all facts. :stuck_out_tongue:
Seriously though, there are 20 ways to skin a cat:
10 seem to work
6 work OK
3 are acceptable
1 is right

Generally speaking, @josecgomez will offer the 1.

1 Like

Can you email me at “email redacted for your own protection” and I can email you what we are looking for.

1 Like

Hahah Jose just saved your life!

Ha seems he saves a lot of lives… and so do you @Chris_Conn!

2 Likes