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. Image for the cookie policy date

Custom filter gives exception when different data type entered

We're using v4.401.0.51, with the grid bound to a generic list of custom objects.

When applying a customer filter to a column, if the wrong data type is entered, we get an exception.

For example, if the column holds an integer, and someone sets up a filter which checks for the value being equal to 'jim' (or even just a blank), we get the following exception:

Object must be of type Int32

The stack trace shows it's using Int32's CompareTo() method, but doesn't reveal anywhere obvious to add exception handling:

----------------------------------------------------------
System.ArgumentException: Object must be of type Int32.
at System.Int32.CompareTo(Object value)
at Syncfusion.Grouping.Internals.SortColumnComparer._Compare(Object x, Object y)
at Syncfusion.Grouping.FilterCondition.CompareRecord(Record record)
at Syncfusion.Grouping.RecordFilterDescriptor._CompareRecord(Record record)
at Syncfusion.Grouping.RecordFilterDescriptor.CompareRecord(Record record)
at Syncfusion.Grouping.RecordFilterDescriptorCollection.CompareRecord(Record record)
at Syncfusion.Grouping.Record.MeetsFilterCriteria()
at Syncfusion.Grouping.Record.GetCounter()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterEntry.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounter.GetCounterTotal()
at Syncfusion.Grouping.Internals.ElementTreeTable.get_VisibleCount()
at Syncfusion.Grouping.DetailsSection.GetVisibleCount()
at Syncfusion.Grouping.Section.GetCounter()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterEntry.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounterBranch.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounter.GetCounterTotal()
at Syncfusion.Collections.BinaryTree.TreeTableWithCounter.GetEntryAtCounterPosition(ITreeTableCounter start, ITreeTableCounter searchPosition, Int32 cookie, Boolean preferLeftMost)
at Syncfusion.Collections.BinaryTree.TreeTableWithCounter.GetEntryAtCounterPosition(ITreeTableCounter searchPosition, Int32 cookie, Boolean preferLeftMost)
at Syncfusion.Grouping.Internals.ElementTreeTable.GetEntryAtCounterPosition(ITreeTableCounter searchPosition, Int32 counterKind, Boolean leftMost)
at Syncfusion.Grouping.Internals.ElementHelper.GetEntryAtCounterPosition(Element el, ITreeTableCounter counter)
at Syncfusion.Grouping.Internals.ElementHelper.__FindElement(Table _table, ITreeTableCounter index, Type t, Boolean stepInNestedTables)
at Syncfusion.Grouping.Internals.ElementHelper.FindElement(Table _table, ITreeTableCounter index, Boolean stepInNestedTables)
at Syncfusion.Grouping.RuntimeElementsInTableCollection.get_Item(Int32 index)
at Syncfusion.Grouping.RuntimeElementsInTableCollectionEnumerator.Reset()
at Syncfusion.Grouping.RuntimeElementsInTableCollectionEnumerator..ctor(RuntimeElementsInTableCollection collection)
at Syncfusion.Grouping.RuntimeElementsInTableCollection.GetEnumerator()
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.InternalGetFrozenRows()
at Syncfusion.Windows.Forms.Grid.GridControlBase.GetVScrollPixelMinimum()
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.PointToNestedDisplayElement(Point ptClient)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.OnCellTipsMouseMove(MouseEventArgs e)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.OnMouseMove(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseMove(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at Syncfusion.Windows.Forms.ScrollControl.WndProc(Message& msg)
at Syncfusion.Windows.Forms.Grid.GridControlBase.WndProc(Message& msg)
at Syncfusion.Windows.Forms.Grid.Grouping.GridTableControl.WndProc(Message& msg)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
----------------------------------------------------------

Is there a way to prevent or catch this exception?

Thanks,
Grant


5 Replies

MA Mahendran Syncfusion Team February 14, 2011 03:43 AM UTC

Hi Grant,

Thanks for your interest in Syncfusion products.

We have checked with your query.The stated exceptions will be resolved in our latest versions upto V 8.x.
Please migrate to our new version.Probably this will vanish your stated exceptions.

Please let me know if you have any concerns.

Regards
R.Mahendran




GC Grant Crofton February 14, 2011 09:41 AM UTC

Hi Mahendran, unfortunately upgrading isn't an option at the moment. Do you know if there's a workaround for this, for example an exception handler somewhere that we could catch it?

Thanks,
Grant



NR Nirmal Raja Syncfusion Team February 21, 2011 03:54 AM UTC

Hi Grant,

We regret for the inconvenience caused.

In both the versions we tried with several samples and unable to reproduce the issue in our side. Please provide us a sample that reproduce the issue, which would be helpful for us to have further analysis.

Let me know if you have any concern.

Regards,
Nirmal



GC Grant Crofton February 21, 2011 02:12 PM UTC

It's Ok, we've gotten around it by wrapping everything which will be displayed in the grid in our own generic type, which includes an overloaded CompareTo() with an exception handler. Something like:

Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo

Try
Return _value.CompareTo(CType(obj, Wrapper(Of T))._value)
Catch ex As Exception
Return 1
End Try
End Function



NR Nirmal Raja Syncfusion Team February 24, 2011 03:59 AM UTC

Hi Grant,

We are glad to know that the issues has been resolved at your end. Please let me know if you have any concern.

Regards,
Nirmal


Loader.
Live Chat Icon For mobile
Up arrow icon