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

Application crashes when clicked on Filter Context menu in RadGrid

5 Answers 271 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rama
Top achievements
Rank 1
Rama asked on 16 Sep 2008, 06:50 AM
I am using GridView for Winforms and the data is bound using a dataset. One of the columns in the dataset's table is an integer column. I have enabled Filter's for this column in GridView and this shows up as a funnel. When I right click on the funnel, there is a context menu with all the filtering options (No filter,Equals,Not Equals etc). When I click on the "Between" menu item in this context menu, the application crashes with the System.Argument exception {"Not enough values."}. The complete stack trace below.
How can we fix this behaviour, Is there any way to programatically disable some of the menu items.


Stack Trace:
   at Telerik.WinControls.UI.Code.Data.Filtering.FilterFunction.CheckParameters(Object[] values)
   at Telerik.WinControls.UI.Code.Data.Filtering.FilterFunction.GetFunctionString(String fieldName, Object[] values)
   at Telerik.WinControls.Data.FilterExpression.AppendPredicateString(StringBuilder result, FilterPredicate predicate, String format)
   at Telerik.WinControls.Data.FilterExpression.ToString()
   at Telerik.WinControls.Data.FilterExpressionCollection.ToString()
   at Telerik.WinControls.Data.DataAccessComponent.Telerik.WinControls.Data.ExpressionHelper.IExpressionChangeNotificationConsumer.FilterExpressionChanged()
   at Telerik.WinControls.Data.ExpressionHelper.FilterExpressionsChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.ExpressionFieldCollection`1.NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.ItemObservableCollection`1.OnItemPropertyChanged(Object sender, EventArgs e)
   at Telerik.WinControls.Data.NotifyPropertyBase.SignalPropertyChanged()
   at Telerik.WinControls.Data.NotifyPropertyBase.OnPropertyChanged(PropertyChangedEventArgs e)
   at Telerik.WinControls.Data.FilterExpression.OnPropertyChanged(PropertyChangedEventArgs e)
   at Telerik.WinControls.Data.FilterExpression.Predicates_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.ObservableCollection`1.NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.ExpressionFieldCollection`1.NotifyListenersCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
   at Telerik.WinControls.Data.ItemObservableCollection`1.OnItemPropertyChanged(Object sender, EventArgs e)
   at Telerik.WinControls.Data.NotifyPropertyBase.SignalPropertyChanged()
   at Telerik.WinControls.Data.NotifyPropertyBase.OnPropertyChanged(PropertyChangedEventArgs e)
   at Telerik.WinControls.Data.NotifyPropertyBase.SetProperty[T](String propertyName, T& propertyField, T value)
   at Telerik.WinControls.Data.FilterPredicate.set_Function(GridKnownFunction value)
   at Telerik.WinControls.UI.GridFilterCellElement.ChangeFilter(RadGridFilterFunctionMenuItem menuItem)
   at Telerik.WinControls.UI.GridFilterCellElement.FilterFunctionButton.item_Click(Object sender, EventArgs e)
   at Telerik.WinControls.RadItem.OnClick(EventArgs e)
   at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
   at Telerik.WinControls.UI.RadMenuItemBase.OnClick(EventArgs e)
   at Telerik.WinControls.UI.RadMenuItem.OnClick(EventArgs e)
   at Telerik.WinControls.RadItem.DoClick(EventArgs e)
   at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
   at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
   at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
   at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at Telerik.WinControls.RadControl.WndProc(Message& m)
   at Telerik.WinControls.UI.RadPopupControl.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(Int32 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(Form mainForm)
   at Microsoft.AdCenter.CommunityPlatform.UI.Desktop.Program.Main() in d:\CpDev\private\src\UI\Desktop\Program.cs:line 17
   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

5 Answers, 1 is accepted

Sort by
0
Jordan
Telerik team
answered on 17 Sep 2008, 11:30 AM
Hello Rama,

This is a known issue that was fixed last week. The fix will be available in the next release of RadControls for WinForms. And for now you can workaround the issue by creating the filter for the column with two parameters like:
 
FilterExpression filter = new FilterExpression(FilterExpression.BinaryOperation.AND, GridKnownFunction.EqualTo, 
                GridFilterCellElement.ParameterName, GridFilterCellElement.ParameterName2); 
 
            this.radGridView1.Columns["ID"].Filter = filter; 

You should note that the filter cell editor cannot be used for editing the values in a complex filter function that requires more than one parameter like Between - in this case the custom filter dialog should be used. The fix that I mentioned includes automatic showing of that dialog when a complex filer function is selected.

 
Best wishes,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 03 Nov 2008, 10:27 AM
Hello,
I have the same problem.
I don't understand, how I can use the workaround. How can I examine in the event FilterChanging, which kind of filter is used?
For a reference I would be grateful.
Christian
0
Jordan
Telerik team
answered on 05 Nov 2008, 07:10 PM
Hi Christian,

There is no need to use this code in theFilterChanging event handler.
It is much easier to put it for example at the end of the constructor of your form that contains the RadGridView control or at the end of the OnLoad override.

Best wishes,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Christian
Top achievements
Rank 1
answered on 13 Nov 2008, 01:49 PM
Hi,
thank you.
But I have the still following questions:
a) How can I recognize, which kind of filter of the users used? Only when selecting the filter 'Between' a further form for the input of the data should be displayed.
b) How can I determine, which data type is present in the selected column?

For hints I am grateful.
Christian
0
Jordan
Telerik team
answered on 14 Nov 2008, 05:07 PM
Hello Christian,

Currently the custom filter dialog is displayed when the user selects a custom filter function or a composite one (with more than one parameters like for example Between). We are planning to extend the filtering functionality of RadGridView to allow you more control over it, so any suggestions are most welcome.

And at the moment in order to know when the user selects a different filter function you could try subscribing for the CollectionChanged event of the FilterExpressions collection:
this.radGridView1.MasterGridViewTemplate.FilterExpressions.CollectionChanged += new Telerik.WinControls.Data.NotifyCollectionChangedEventHandler(FilterExpressions_CollectionChanged); 

or if you are interested in changes of the filter for a specific column you could subscribe to the PropertyChanged event if its filter:
this.radGridView1.Columns[0].Filter.PropertyChanged += new PropertyChangedEventHandler(Filter_PropertyChanged); 


You can easily examine the type of data in a column using its DataType property like below:
Type firstColumnType = this.radGridView1.Columns[0].DataType; 



All the best,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Rama
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Christian
Top achievements
Rank 1
Share this question
or