Filtering an EpiCombo

More Examples for the sake of the thread.

image
image

You can also use SQL Functions, Ice SQL Functions.

Behind The Scenes

SearchFilter + EpiFilters + EpiFiltersAppend are just combined and executed against SQL (they are not post-filters).

Also just for the record, if your SearchFilter starts with CodeTypeID Epicor will set the DropDownStyle Automatically to DropDownList. So you dont have to set it in Code anymore.

5 Likes

Hi guys, @hmwillett , @hkeric.wci @josecgomez
Just a quick question. Everything is working great except for one small problem. When we save the Project Customer as the one we select from the dropdown list, it reverts back to the entry at the top of the list the next time we open the memo. I have bound the control to the ProjectCustomer field in MemoUD table, but it seems the list generation for the combobox is overwriting the content every time. Is there a way to display the value that was saved, it is after all in the list, just not always at the top. I have experimented a bit with the properties but had no luck as yet.

I figured it out eventually. I needed Character01 in the ValueMember, not Key1. As Key1 is the Project Number it obviously did not exist in the Project Customer list. Seems fine now.

1 Like

What if valuemember name is character01, would the filter work out?? or what would be the epifilter in that case??

Leapfrogging off this, also for posterity, here’s a method for dynamically updating the combo list based on the value of another field, in a way that lets you embed an combo within a grid allowing for each row to have a different filter. It’s great for when you want to create a two-drop down category/subcategory setup. Took me longer than I’d like to pull all the pieces together. Thankfully Infragistics has extensive (albeit hard to navigate) documentation.

//Adding EventHandlers.
public void InitializeCustomCode()
{
	YourGrid.BeforeCellListDropDown += new CancelableCellEventHandler(YourGrid_BeforeCellListDropDown);
	YourGrid.AfterCellListCloseUp += new CellEventHandler(YourGrid_AfterCellListCloseUp);
}

public void DestroyCustomCode()
{
	YourGrid.BeforeCellListDropDown -= new CancelableCellEventHandler(YourGrid_BeforeCellListDropDown);
	YourGrid.AfterCellListCloseUp -= new CellEventHandler(YourGrid_AfterCellListCloseUp);
}

/*You have two controls: the UltraGrid, and also a ComboBox somewhere on the form.
The combo can even be hidden. You configure the combo normally.
Then put this into a form_load method.
*/
private void YourForm_Load(object sender, EventArgs args)
{
	YourGrid.DisplayLayout.Bands[0].Columns["YourFilteredField"].ValueList = YourCombo;
	YourGrid.DisplayLayout.Bands[0].Columns["YourFilteredField"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
	YourCombo.ForceRefreshList();
}

/*Sets the dropdown filter. Fires when you click any dropdown in a grid.
Therefore, it's setting the filter right before it retrieves the values.*/
private void YourGrid_BeforeCellListDropDown(object sender, CancelableCellEventArgs args)
{
	EpiUltraGrid grid = (EpiUltraGrid)sender;

	if (grid.ActiveCell.Column.Key == "YourFilteredField")
	{
		EpiCombo cmb = (EpiCombo)grid.ActiveCell.ValueListResolved;
		//This specific implementation was for a category/subcategory setup.
		//You can, of course, get as creative as you want for the filter.
		cmb.EpiFilters = new[] { "YourFilteredField LIKE '?[FilteringField,'zz']-%'" };
		//'?[field,'string']' syntax will return the string if the field is null.
		cmb.ForceRefreshList();
	}
}

/*This clears the filter after the dropdown closes. 
If you don't do this, you will lose the description text for all grid rows
that don't match your filter. It will show the value code instead.*/
private void YourGrid_AfterCellListCloseUp(object sender, CellEventArgs args)
{
	EpiUltraGrid grid = (EpiUltraGrid)sender;

	if (grid.ActiveCell.Column.Key == "YourFilteredField")
	{
		EpiCombo cmb = (EpiCombo)grid.ActiveCell.ValueListResolved;
		cmb.EpiFilters = null;
		cmb.ForceRefreshList();
	}
}
3 Likes