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

Filtering in RadGridView with GridViewMultiComboBoxColumn

4 Answers 182 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mako
Top achievements
Rank 1
Mako asked on 12 Jan 2012, 01:44 PM
Hi,

I am having problems with using MultiComboboxes in GridView while using the filter bar.
Normal editing is ok after I have handled the RadGridView1_CellEditorInitialized event
If I click on the filter bar column and then select a value it throws this error:

System.Reflection.TargetInvocationException was unhandled
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
       at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Delegate.DynamicInvoke(Object[] args)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
       at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at Telerik.WinControls.RadControl.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(ApplicationContext context)
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at RMS.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
  InnerException: System.NullReferenceException
       Message=Object reference not set to an instance of an object.
       Source=Telerik.WinControls.GridView
       StackTrace:
            at Telerik.WinControls.UI.ScrollableRowsContainerElement.RemoveElement(Int32 position)
            at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureElements()
            at Telerik.WinControls.UI.BaseVirtualizedContainer`1.MeasureOverride(SizeF availableSize)
            at Telerik.WinControls.UI.ScrollableRowsContainerElement.MeasureOverride(SizeF availableSize)
            at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
            at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
            at Telerik.WinControls.UI.RowsContainerElement.MeasureOverride(SizeF availableSize)
            at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
            at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
            at Telerik.WinControls.UI.ScrollViewElement`1.MeasureView(SizeF availableSize)
            at Telerik.WinControls.UI.ScrollViewElement`1.MeasureOverride(SizeF availableSize)
            at Telerik.WinControls.UI.GridTableElement.MeasureOverride(SizeF availableSize)
            at Telerik.WinControls.RadElement.MeasureCore(SizeF availableSize)
            at Telerik.WinControls.RadElement.Measure(SizeF availableSize)
            at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayout()
            at Telerik.WinControls.Layouts.ContextLayoutManager.UpdateLayoutCallback(ILayoutManager manager)
       InnerException:

the InnerException shows a System.NullReferenceException so I tried to force the filter value by handling the editor_TextChanged event, the code runs but the error is still thrown, code below:

Private Sub RadGridView1_CellEditorInitialized(sender As Object, e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles RadGridView1.CellEditorInitialized
    Try
        Dim editor As Telerik.WinControls.UI.RadMultiColumnComboBoxElement = TryCast(e.ActiveEditor, Telerik.WinControls.UI.RadMultiColumnComboBoxElement)
        If editor IsNot Nothing AndAlso editor.Columns IsNot Nothing Then
            With editor
                If .ValueMember = "pkPostID" Then
                    .Columns("pkPostID").IsVisible = False
                    .Columns("tPostUPN").HeaderText = "UPN"
                    .Columns("tJobTitleName").HeaderText = "Job Title"
                    .Columns("dtPostStart").HeaderText = "Start Date"
                    .Columns("dtPostEnd").HeaderText = "End Date"
                ElseIf .ValueMember = "pkEmployeeID" Then
                    .Columns("pkEmployeeID").IsVisible = False
                    .Columns("lEmployeeNumber").HeaderText = "Emp Num"
                    .Columns("tEmployeeFirstName").HeaderText = "First Name"
                    .Columns("tEmployeeLastName").HeaderText = "Last Name"
                End If
                .AutoSizeDropDownToBestFit = True
                .AutoFilter = True
                RemoveHandler editor.TextChanged, AddressOf editor_TextChanged
                AddHandler editor.TextChanged, AddressOf editor_TextChanged
            End With
        End If
    Catch ex As Exception
        Call MessageBox.Show(ex.Message)
    End Try
End Sub
 
Private Sub editor_TextChanged(sender As Object, e As System.EventArgs)
    Try
        Dim editor As Telerik.WinControls.UI.RadMultiColumnComboBoxElement = DirectCast(Me.RadGridView1.ActiveEditor, Telerik.WinControls.UI.RadMultiColumnComboBoxElement)
        With editor
            If .ValueMember = "pkPostID" Then
                With .EditorControl
                    With .MasterTemplate.FilterDescriptors
                        .Remove("filterUPN")
                        .Add("filterUPN", Telerik.WinControls.Data.FilterOperator.IsEqualTo, editor.Value)
                    End With
                    .TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.FilteringChanged)
                End With
            ElseIf .ValueMember = "pkEmployeeID" Then
                With .EditorControl
                    With .MasterTemplate.FilterDescriptors
                        .Remove("filterEmpNum")
                        .Add("filterEmpNum", Telerik.WinControls.Data.FilterOperator.IsEqualTo, editor.Value)
                    End With
                    .TableElement.Update(Telerik.WinControls.UI.GridUINotifyAction.FilteringChanged)
                End With
            End If
        End With
    Catch ex As Exception
        Call MessageBox.Show(ex.Message)
    End Try
End Sub

If I select filters on other columns that are not MultiComboboxes they work without error.

I only have 2 columns in the grid that use multicomboboxes, the ValueMember and DisplayMember values are as follows:
Column 1 "POST"
ValueMember = "pkPostID" underlaying value datatype is Integer32
DisplayMember = "tPostUPN" underlaying value datatype is String

Column 2 "Employee"
ValueMember = "pkEmployeeID" underlaying value datatype is Integer32
DisplayMember = "lEmployeeNumber" underlaying value datatype is Integer32

the data is types and values are the same in the GridViewMultiComboBoxColumn elements.

Any help/ideas would be most welcome.

Thanks 

Wayne Steel

4 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 13 Jan 2012, 02:17 PM
Hello Wayne,

This issue is addressed in our latest release - Q3 2011 SP1. Please find the full answer to your question in your support ticket regarding the same issue. Please avoid posting the same question twice as this may slow down our response. If you need a quicker response, please directly open a support ticket.

If you have any other questions, feel free to ask.
 
Greetings,
Jack
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

0
Mako
Top achievements
Rank 1
answered on 16 Jan 2012, 11:22 AM
Hi Jack,

Thanks for that, indeed the issue is resolved in the latest release.

Something you should keep an eye on though is we thought we had the latest version of Winforms, and when we double checked in the upgrade project tool we found it was still 2011 Q2 and clicking on updates said we had the latest version, had to download manually and install etc.

Just so you know.

Thanks

Wayne
0
Erjan Gavalji
Telerik team
answered on 17 Jan 2012, 09:38 AM
Hi Wayne,

Thanks for the update, this note is really important for the Telerik VSXTeam.

Not sure of the reason to not get the Q3 2011 release reported as available. Moreover, I guess it is now not reproducible after you've installed the latest version. There is something we could monitor though and I'll appreciate your feedback on:
The next major release is coming about mid-end February. Can you check if the update notifications are enabled through the the Telerik -> VSExtensions Options dialog in your Visual Studio? If yes, let me know if you got notified about the availability of the latest version. We test these on each update, but still, there could be a condition on a customer machine that could prevent the notification/detection from being displayed.

Thanks in advance,
Erjan Gavalji
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

0
Mako
Top achievements
Rank 1
answered on 17 Jan 2012, 10:38 AM
Hi Erjan,

Will do, and I can comfirm the notifications are/were enabled.

We've been getting updates for JustCode and JustTrace, I'll look at the rest of our installed Telerik packages to see if they need updating and inform you before I update if happens again.

Thanks

Wayne
Tags
GridView
Asked by
Mako
Top achievements
Rank 1
Answers by
Jack
Telerik team
Mako
Top achievements
Rank 1
Erjan Gavalji
Telerik team
Share this question
or