This question is locked. New answers and comments are not allowed.
I'm trying to bind a RadGridView to a list of x, where x has a property called Attributes which is a Dictionary(of String, Object). The binding works correctly for display and the items in the grid are sortable. However, the filtering is not working. When a column is populated with numeric values, the unique values filter box is displayed but nothing happens when you click on the checkbox beside a unique value. When a column is populated with string values, the unique values filter is displayed but the filter only shows the first matching record after checking a unique value, even though there are more records that contain that value.
If I changed my code to bind to a Dictionary(of String, String), the filtering works perfectly. Is there something I can do to get filtering to work with a Dictionary(of String, Object)?
Here is my sample code:
If I changed my code to bind to a Dictionary(of String, String), the filtering works perfectly. Is there something I can do to get filtering to work with a Dictionary(of String, Object)?
Here is my sample code:
Private Sub MainPage_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded
Dim lyrData As List(Of LayerData) = GetLayerData()
Dim ga As GraphicAttributeColumn
For i As Integer = 0 To lyrData(0).Attributes.Count - 1
Dim key As String = lyrData(0).Attributes.Keys.ElementAt(i)
ga = New GraphicAttributeColumn
ga.AttributeName = key
Me.RadGridView1.Columns.Add(ga)
Next
RadGridView1.ItemsSource = lyrData
End Sub
Private Function GetLayerData() As List(Of LayerData)
Dim data As New List(Of LayerData)
For j As Integer = 1 To 10
Dim attributes As New Dictionary(Of String, Object)
attributes.Add("ID", j)
attributes.Add("Mod", (j Mod 2).ToString)
attributes.Add("Description", String.Format("Description: {0}", j Mod 2))
attributes.Add("Quantity", New Random().[Next](500))
attributes.Add("Address", String.Format("Address: {0}", j))
data.Add(New LayerData(True, attributes))
Next
Return data
End Function
Public Class GraphicAttributeColumn
Inherits Telerik.Windows.Controls.GridViewDataColumn
Private _attributeName As String
Public Sub New()
End Sub
Public Property AttributeName() As String
Get
Return _attributeName
End Get
Set(ByVal value As String)
Dim b As System.Windows.Data.Binding = New System.Windows.Data.Binding("Attributes[" & value & "]")
Me.DataMemberBinding = b
_attributeName = value
End Set
End Property
Public Overrides Function CanSort() As Boolean
Return True
End Function
Public Overrides Function CanFilter() As Boolean
Return True
End Function
End Class
Public Class LayerData
Private m_IsSelected As Boolean
Private m_Attributes As Dictionary(Of String, Object)
Public Property IsSelected() As Boolean
Get
Return m_IsSelected
End Get
Set(ByVal value As Boolean)
m_IsSelected = value
End Set
End Property
Public Property Attributes() As Dictionary(Of String, Object)
Get
Return m_Attributes
End Get
Set(ByVal value As Dictionary(Of String, Object))
m_Attributes = value
End Set
End Property
Public Sub New()
End Sub
Public Sub New(ByVal isSelectecd As Boolean, ByVal attributes As Dictionary(Of String, Object))
Me.IsSelected = isSelectecd
Me.Attributes = attributes
End Sub
End Class