Hi,
I have a databoundgrid with a column set to combobox - the datasource of the dropdown column is a dataview, the ValueMember is an integer, and the DisplayMember is a string.
When the filter bar is set, it lists in the drop down the ValueMembers - is there anyway to have it list the DisplayMember instead? If the grid is using ComboBoxes to provide lookup values, its not very useful having a list of the underlying user-unfriendly data in the filter bar.
Thanks
Jeremy
AD
Administrator
Syncfusion Team
May 15, 2003 11:51 AM UTC
This is on our list of things to add. Currently, you would have to derive GridFilterBar to implement this functionality. It would take some coding to get things fully implemented through a derived class.
It is too late to get this into the upcoming 1.6 release, but we will try to have it for the first point release after that.
UN
Unknown
Syncfusion Team
May 15, 2003 12:29 PM UTC
I'm already deriving from the Filterbar class. However, I can't determine at what point the drop down is filled - which event should I be looking at?
Thanks
Jeremy
AD
Administrator
Syncfusion Team
May 15, 2003 03:15 PM UTC
Its done in WireGrid.
There are several technical points that need to be handled to do things in general. Attached is a incomplete project I started this morning to try to gauge how difficult this would be in a derived class. It seems to work as long as you are just filtering the single column, but fails when you try to add filters from other columns.
UN
Unknown
Syncfusion Team
May 15, 2003 03:38 PM UTC
Clay
Thanks very much - works like a dream
Regards
Jeremy
UN
Unknown
Syncfusion Team
May 15, 2003 08:02 PM UTC
I changed CreateEntries to the following. It now works with filters in multiple columns
Protected Overrides Function GetFilterFromRow(ByVal grid As Syncfusion.Windows.Forms.Grid.GridDataBoundGrid) As String
Dim filter As String = MyBase.GetFilterFromRow(grid)
Dim rowIndex As Integer = Me.GetFilterRow
Dim gbcc As GridBoundColumnsCollection = CType(IIf(grid.GridBoundColumns.Count = 0, grid.Binder.InternalColumns, grid.GridBoundColumns), GridBoundColumnsCollection)
Dim a As String() = filter.Split("["c)
For Each gbc As GridBoundColumn In gbcc
Dim fieldName As String = "[" & gbc.MappingName & "]"
If filter.IndexOf(fieldName) > -1 Then
If gbc.StyleInfo.CellType = "ComboBox" AndAlso Not gbc.StyleInfo.DataSource Is Nothing AndAlso gbc.StyleInfo.ValueMember <> gbc.StyleInfo.DisplayMember Then
Dim colIndex As Integer = grid.Binder.NameToColIndex(gbc.MappingName)
Dim row As DataRow = CType(grid(rowIndex, colIndex).CellModel.BindingContext(grid(rowIndex, colIndex).DataSource).Current, DataRowView).Row
Dim s As String = row.Item(gbc.StyleInfo.ValueMember).ToString
Dim s1 As String = row.Item(gbc.StyleInfo.DisplayMember).ToString
For i As Integer = 0 To a.Length - 1
If a(i).IndexOf(gbc.MappingName) > -1 Then
a(i) = a(i).Replace(s1, s)
End If
Next
End If
End If
Next
filter = String.Join("[", a)
Return filter
End Function
Jeremy