This is a migrated thread and some comments may be shown as answers.

Custom columns on GridView crash when click on filter icon

0 Answers 65 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Andreas
Top achievements
Rank 1
Andreas asked on 23 Feb 2012, 03:59 PM

Hello

I have a GridView that includes static and dynamic columns. When I try to use the filtering on the dynamic columns I get a pop-up unhanded exception message (attached file). All dynamic rows have data inside of type string. This is a sample code 

                     Dim index = 0
                        For Each oCustomIndex As CustomIndex In oDocument.CustomIndexes
                            If (oRadGridDocumentSearchResults.Columns(oCustomIndex.Name) Is NothingThen
                                Dim oGridViewColumn As New GridViewDataColumn()
                                oGridViewColumn.Header = oCustomIndex.Name.Replace("_"" ")
                                oGridViewColumn.UniqueName = oCustomIndex.Name
                                oGridViewColumn.IsFilterable = True
                                oGridViewColumn.IsGroupable = True
                                oGridViewColumn.IsReadOnly = True
                                oGridViewColumn.IsSortable = True
                                oGridViewColumn.DataType = GetType(String)
                                oGridViewColumn.DataMemberBinding = New Binding(".")
                                oGridViewColumn.DataMemberBinding.Mode = BindingMode.OneWay
                                oGridViewColumn.DataMemberBinding.Converter = New CustomIndexesToStringConverter()
                                oGridViewColumn.DataMemberBinding.ConverterParameter = index
                                oCustomColumnCollection.Add(oGridViewColumn)
                                oRadGridDocumentSearchResults.Columns.Add(oGridViewColumn)
                                index += 1
                            End If
                        Next

Public Class CustomIndexesToStringConverter
    Implements IValueConverter
 
    Public Function Convert(ByVal value As ObjectByVal targetType As System.TypeByVal parameter As ObjectByVal culture As System.Globalization.CultureInfoAs Object Implements System.Windows.Data.IValueConverter.Convert
        Try
            Dim oMVDocument As MVDocument = value
            Dim oString As String = oMVDocument.CustomIndexes(parameter).Value
            Return oString
        Catch ex As Exception
            ReportError(ex.Message, GetCurrentMethod.Name)
        End Try
        Return Nothing
    End Function
 
    Public Function ConvertBack(ByVal value As ObjectByVal targetType As System.TypeByVal parameter As ObjectByVal culture As System.Globalization.CultureInfoAs Object Implements System.Windows.Data.IValueConverter.ConvertBack
        Return Nothing     End Function End Class

Thanks

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Andreas
Top achievements
Rank 1
Share this question
or