Hi
When I use the default filter provider in an UltraWinGrid 10.3, the options displayed in the filter drop down for a column are all the distinct values for that column that are currently filtered in on the associated grid. There may be more values in the underlying data source, but the default filter provider only shows those that currently appear in the grid.
When I use the more powerful UltraGridFilterUIProvider to give Excel style filtering, all values are displayed in the filter drop down, irrespective of the current filtering applied to the grid.
My users often use the filter dropdowns as a narrowing search facility, with each subsequent filter narrowing the values in the remaining non-filtered columns.
Is there a way of configuring the custom UI provider to only show filtered in column values?
Many thanks in advance
Jon
If you don't really need the functionality of the UltraGridFilterUIProvider for advanced filters, you could use the BeforeRowFilterDropDownPopulate of the WinGrid. Below is an example of how I achieved what you're asking. Use this code without having the UltraGridFilterUIProvider tied to the grid, otherwise you might get some odd results in the drop down. It might not be the best way, so we'll see if the Infragistics Team chimes in.
private void ultraGrid1_BeforeRowFilterDropDownPopulate(object sender, BeforeRowFilterDropDownPopulateEventArgs e) { e.ValueList.ResetValueListItems(); foreach (UltraGridRow gridRow in ultraGrid1.Rows.GetFilteredInNonGroupByRows()) { String cellValue = gridRow.GetCellValue(e.Column).ToString(); if (e.ValueList.FindStringExact(cellValue, -1) == -1) continue; e.ValueList.ValueListItems.Add(new Infragistics.Win.ValueListItem(cellValue)); } }
Thanks for the reply. If I don't use the UltraGridFilterUIProvider then I don't need to do anything as the default grid filtering already behaves in this manner. It's the advanced filtering and the multi-select that I need which is why I went for the Excel style filter provider, but that doesn't filter the filter options.
I had a look at the Before/AfterMenuPopulate Events on the UIProvider, but I was rather hoping there'd be a simple config setting that I was missing.
Cheers
This code below should do the trick, but might need further optimized as I've been awake for over 30 hours now and need to get some rest before doing more programming. It's all starting to blur together.
It uses the BeforeRowFilterDropDown of the grid event, to customize the value list of items that appear in the tree when you're using UltraGridFilterUIProvider control.
private void ultraGrid1_BeforeRowFilterDropDown(object sender, BeforeRowFilterDropDownEventArgs e) { UltraGridRow[] FilteredRows = ultraGrid1.Rows.GetFilteredInNonGroupByRows(); Boolean isRemoved = false; if (typeof(string) == e.Column.DataType) { for (int i = e.ValueList.ValueListItems.Count - 1; i >= 0; i--) { if (e.ValueList.ValueListItems[i].DisplayText.Equals("(All)")) continue; if (e.ValueList.ValueListItems[i].DisplayText.Equals("(Custom)")) continue; if (e.ValueList.ValueListItems[i].DisplayText.Equals("(Blanks)")) continue; foreach (UltraGridRow gridRow in FilteredRows) { if (e.ValueList.ValueListItems[i].DisplayText == gridRow.GetCellValue(e.Column).ToString()) { isRemoved = false; break; } isRemoved = true; } if (isRemoved) e.ValueList.ValueListItems.RemoveAt(i); } } }
Thanks a lot - works well. I'll play with it to extend to date & decimal fields.
Sleep well!Jon