We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

filterbar question

I setup a filter bar on a GDBG with the code below. I setup a check box on the form that filters the grid with the code below.
theFilterBar.RowFilter = "([Status] <> 'Signed PA' and [Status] <> 'Docs Received' and [Status] <> 'Prelim Received')"

the problem I have is when the filter above is applied and then a user selects a filter option the rowfilter does not use the code from the check box. Why does the dropdown selection remove any existing value in the rowfilter?

theFilterBar = New MyGridFilterBar()
AddHandler theFilterBar.FilterBarFilterCompleted, AddressOf RecordCount
AddHandler theFilterBar.FilterBarTextChanged, AddressOf GridFilterBarTextChanged
Dim style As New GridStyleInfo
style.ModifyStyle(Me.dgEng.BaseStylesMap("Header").StyleInfo, Syncfusion.Styles.StyleModifyType.Copy)
style.CellType = "ComboBox"
style.ExclusiveChoiceList = True
style.BaseStyle = "Standard"
style.Font.Bold = False
style.Borders.Bottom = New GridBorder(GridBorderStyle.Dashed)
style.DropDownStyle = GridDropDownStyle.AutoComplete
theFilterBar.WireGrid(Me.dgEng, style)


3 Replies

AD Administrator Syncfusion Team October 19, 2007 11:45 AM UTC

Here is something to try to avoid this problem.

Instead of adding the initial filter to the FilterBar.RowFilter, instead apply it to the DataView object associated with the bound datasource. Here is some code.


CurrencyManager cm = grid.BindingContext[grid.DataSource, grid.DataMember] as CurrencyManager;
DataView dv = cm.List as DataView;
dv.RowFilter = "([Status] <> 'Signed PA' and [Status] <> 'Docs Received' and [Status] <> 'Prelim Received')"



PR Patrick Rumery October 19, 2007 05:19 PM UTC

it only works if the drop downs are chosen first then the quick filter is applied. if the quick filter is done first the drop down selection will erase it. Do you know the event that is fired when the drop down option is selected? Maybe I can stop it from clearing the current filter string.


AD Administrator Syncfusion Team October 20, 2007 08:27 AM UTC

In order for an existing filter to be preserved by a filterbar filter, the existing filter has to have been applied before the filterbar was wired. Here is a sample showing this working. The datatable has 50 rows but comes up with only 46 becuse Col1 is filtered initially to not show 1's.

If you cannot have the original filter applied during the wiring of the filterbar for some reason, you can subscribe to the FilterBarFilterCompleted event and reapply both the filterBar filter and your original filter. Here is a little code.


void filterBar_FilterBarFilterCompleted(object sender, GridFilterBarTextChangedEventArgs e)
{
CurrencyManager cm = gridDataBoundGrid1.BindingContext[gridDataBoundGrid1.DataSource, gridDataBoundGrid1.DataMember] as CurrencyManager;
DataView dv = cm.List as DataView;
string yourFilterString = "[Col1] = 1";
dv.RowFilter = string.Format("({0}) AND ({1})", dv.RowFilter, yourFilterString);
}




WindowsApplication25 (2).zip

Loader.
Live Chat Icon For mobile
Up arrow icon