Filtering epiUltraGrid with a BAQComboBox

Hi All!
I have a customized dashboard that shows a grid at the bottom. The grid is populated by a BAQ that requests the part number. It then shows the list of revisions and operations for that part.

I would like to add a dropdown box to the tracker form that lists the available revs for the part. When you choose a rev, the grid should update to be filtered by just the selected rev. That way the grid shows only the operations for one part/rev.

Here is what I have so far. You can see that I have three text boxes at the top that have EPI bindings to the table at the bottom. So whatever part/rev/op you select from the grid at the bottom, it fills in those values.

You can see I created a BAQ to populate the BAQDropdown box. I used some code from here to try to populate the BAQcombo using a value selected from the dashboard grid.

From start to finish: the user should load this dashboard, and enter a part number as a parameter for the source BAQ. This loads up the dashboard with the bottom grid showing all the revisions and operations (PartRev, PartOper) for the parameter part. This part of it works well. However, the BAQ Combo does not populate with anything.

How can I get the BAQCombo to populate with the list of valid Revs (The revs listed in the grid at the bottom.) Then, when I select a value from that combo box, I want to filter the grid to show only the values from the box. I am going to try that part with the code I found here:

I appreciate your time and consideration.
Thank you!
Nate

1 Like

Hi Nate,

In your query, getMyPartRevs, try changing the binding to [EpiBinding:PartRev.PartNum]

You’re using an underscore, mine’s using a period.

select 
	[Resource].[ResourceID] as [Resource_ResourceID]
from Erp.Resource as Resource
where (Resource.ResourceGrpID = '[EpiBinding:WorkQueue.ResourceGrpID]')

I did try that, as well as a few other iterations. By BAQCombo dropdown is still blank.
Could this be a matter of timing? Maybe the BAQCombo is trying to populate when the form is still blank, and then never repopulates after the form has been loaded.

That was going to be my next question. At what point in your code are you trying to run the dynamic query that populated the combobox?

Let me get on my test server and try to replicate this really quick.

I only set the option in the customization tools dialog. I haven’t changed any of the code in the script editor yet. What event should I use to trigger the refresh of the BAQCombo?

In my query, the EpiBinding is a gold color and inside a ‘’, where yours is black and missing the ‘’. I’m thinking this is where the issue is.

1 Like

Try this as a constant,

'[EpiBinding:PartRev.PartNum]'

My result:

image

I started with the quotes in there at first and removed it as part of my trial and error. Adding them back in does not change the behavior. I just added the quotes back in. Where your BAQ says ‘WorkQueue’, should I be using the name of my custom dashboard form? I think I tried that option as well with no luck. I feel like I am missing something obvious. Thanks for your help!

Nope, doesn’t need to be the name of the dashboard.

I exported my query, you can try importing it on your end and see if it comes out correct.
quickie.baq (12.9 KB)

My BAQ looks just like that one you sent now. Still I get no values in my drop down.

Ok, just so I’m understanding correctly, you imported the quickie.baq and the binding isn’t gold like this?

image

The binding looks gold. Here is what I have now for the BAQ code:

select 
	[PartRev].[RevisionNum] as [PartRev_RevisionNum]
from Erp.PartRev as PartRev
where (PartRev.PartNum = '[EpiBinding:PartRev.PartNum]')

I have been trying to insert baqComboC1.Refresh(); under various form events. But nothing seems to work.

Ah, okay. Cool. So the query should work. Now we just have to get it working in the form.

In your form, is the part number control at the top bound to PartRev.PartNum?

Use your refresh on a text changed event on the part number control box.

Yes, The partNum, and partRev are both bound to the grid at the bottom.
I added the refresh to the text box changed event like this:

	private void MyPart_TextChanged(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
baqComboC1.Refresh();
	}

Still no values appearing in the drop down. (Thanks for your continued efforts!) Is there any other information I can post that would help resolve this?
Thanks!
Nate

I added a button that explicitly calls the refresh of the combo box, and every time it refreshes there is nothing in it.

Something about the BAQ must be wrong.

In the BAQ Information section of my BAQComboBox, I have my data column listed as the value and display members (RevisionNum) and the Dynamic Query ID set to my BAQ name (getMyPartRevs). This seems like it should work, but the combo box is always empty.

Sorry, had to go grab some lunch. I had to pull open my customization and do a little digging.

The binding in the BAQ has to match the binding of the object that you’re trying to pull from. In my case, it was WorkQueue.ResourceGrpID.

image

For example, if I wanted to use a BAQcombo and grab the JobNum on the WorkQueue Job Details panel, I’d use [EpiBinding:WorkQueue.JobNum]

Go to your dashboard, open customization, click on your part number control, does it have an EpiBinding? What’s the object.field name? If it’s something like ABCcode.PartNum, that’s what you’re going to use in the BAQ. I’m going to assume it’s not bound to anything though, so this might not work.

So, I could have been wrong earlier. It might be the name of the dashboard, I’m not entirely sure. I haven’t used this method in a dashboard before.

Instead, you may want to use a dynamic query, passing in the part number as a parameter, to fill an EpiUltraCombo (not a BAQcombo, and make sure to use an EpiUltraCombo, not an EpiCombo).

To do this, edit your query to use a parameter called part on the PartRev table.

image

image

In your customization, add DynamicQueryAdapter. (Tools > Wizards > Customization Wizard > Reference Adapter > Launch > Get Adapters > DynamicQueryAdapter > Finish)

image

Add the usings for the adapter we just put in, can’t remember which one it is specifically, but this what I’m using:

using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Reflection;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.UI;
using Ice.BO;
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;
using Infragistics.Win.UltraWinGrid;
using Infragistics.Shared;

Grab the CSM object, call your query with the parameter, and stuff the results into your ultracombo:

cmbpartrev = (Ice.Lib.Framework.EpiUltraCombo)csm.GetNativeControlReference("79b5444d-be67-4daa-abc8-635a50e7fb36");

		DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
		dqa.BOConnect();		
		QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("quickie");
		qeds.ExecutionParameter.Clear();

		qeds.ExecutionParameter.AddExecutionParameterRow("part", txtuser.Text, "nvarchar", false, Guid.NewGuid(), "A");

		dqa.ExecuteByID("quickie", qeds);
		if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
		{
			cmbpartrev.DataSource = dqa.QueryResults.Tables["Results"];
			cmbpartrev.DisplayMember = "PartRev_RevisionNum";
			cmbpartrev.ValueMember = "PartRev_RevisionNum";
			oTrans.NotifyAll();
		}

I’d make the Dynamic Query a function, then put that function in a form event (AfterFieldChange).

Hope this helps!

1 Like

I finally got this working! Thank you so much for the time you put in to explaining this for me. Here is my implementation.
I made a BAQ called getPartRev:

select 
	[PartRev].[RevisionNum] as [PartRev_RevisionNum]
from Erp.PartRev as PartRev
where (PartRev.PartNum = @part)

After I enter a part number I update the combobox datasource using a dynamic query. Then I refresh the combo box to show just the revs for that part:

private void txtMyPart_Leave(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		if (txtMyPart.Text!="")  
		{
		getRevs();
		cmbpartrev.ForceRefreshList();
		}
	}

I added the dynamic query to the function getRevs():

	private void getRevs()
	{
		cmbpartrev = (Ice.Lib.Framework.EpiUltraCombo)csm.GetNativeControlReference("8ba6336e-50bb-4814-9f5d-4c85237c4f81");

		DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
		dqa.BOConnect();		
		QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("getPartRev");
		qeds.ExecutionParameter.Clear();

		qeds.ExecutionParameter.AddExecutionParameterRow("part", myPart.Text, "nvarchar", false, Guid.NewGuid(), "A");

		dqa.ExecuteByID("getPartRev", qeds);
		if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
		{
			cmbpartrev.DataSource = dqa.QueryResults.Tables["Results"];
			cmbpartrev.DisplayMember = "PartRev_RevisionNum";
			cmbpartrev.ValueMember = "PartRev_RevisionNum";
			oTrans.NotifyAll();
		}
	}

I also made sure to define the combobox at the beginning of the class script. This is revCombo:

public EpiUltraCombo cmbpartrev;

To make this work, I had to modify my dashboard tracker view to prompt for part number and rev. I use the native part number text box, but I use customization to hide the native revision text box. This way, I can put the ultra combo box on the customization. Whenever you select a value from the ultracombo, the hidden rev text box gets updated, and the grid refreshed to show the new results.

	private void revCombo_ValueChanged(object sender, System.EventArgs args)
	{
		// ** Place Event Handling Code Here **
		txtMyRev.Text = revCombo.Text;
		MainController.AppControlPanel.HandleToolClick("RefreshTool", new 		Infragistics.Win.UltraWinToolbars.ToolClickEventArgs(MainController.MainToolManager.Tools["RefreshTool"], null));
	}

So far this seems to work great! I learned a lot through this process. Thank you again!
Nate

1 Like

Glad you were able to get this working, I knew you could do it!