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.
Unfortunately, activation email could not send to your email. Please try again.

filterbar question

Thread ID:

Created:

Updated:

Platform:

Replies:

69197 Oct 17,2007 09:14 PM Oct 20,2007 04:27 AM Windows Forms 3
loading
Tags: GridControl
Patrick Rumery
Asked On October 17, 2007 09:14 PM

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)


Administrator [Syncfusion]
Replied On October 19, 2007 07:45 AM

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')"


Patrick Rumery
Replied On October 19, 2007 01:19 PM

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.

Administrator [Syncfusion]
Replied On October 20, 2007 04:27 AM

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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;