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

How do we disable 'filter assist' in the filtering row?

5 Answers 200 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Baris
Top achievements
Rank 1
Baris asked on 07 Dec 2009, 07:52 PM
For columns that are strongly typed (set to System.DateTime, System.Double etc), when you click on the filtering row you get either a drop-down (for DateTime) or small up/down arrows on the right (for Double) which you can use to create your filter.

The problem is, these filters are causing the users more work than just typing the string -- selecting the date from the calendar dropdown or selecting a double value (which in our case have 3+ decimal places) gets hard. You can't just erase all that's in there with just a backspace (in the datetime case it erases only the year) and if you use the up/down arrows for doubles, they go up/down by 1.

I'm hoping there is a way to just disable these and make those filtering cells act just like a string filter. I would remove the types for those columns but that's not an option since I still want the columns to sort properly. I would appreciate your help in disabling the 'filter assist'.

Thanks,
Baris

5 Answers, 1 is accepted

Sort by
0
Accepted
Jack
Telerik team
answered on 08 Dec 2009, 09:22 AM
Hello Baris,

I understand your concerns. Yes, currently you must replace all GridViewTextBoxColumn(s) to have textbox editors in the filtering row. However, you can replace the default editor for a numeric column to be RadTextBoxEditor. This will not work for the checkbox column and the date time column. Please consider the code below:

void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    if (this.radGridView1.CurrentRow is GridViewFilteringRowInfo)
    {
        e.EditorType = typeof(RadTextBoxEditor);
    }
}

If you have any suggestion on how to improve this behavior, please share it with us. We will appreciate that.

Greetings,

Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Baris
Top achievements
Rank 1
answered on 08 Dec 2009, 01:04 PM
Hi Jack,

Thanks for your quick response, I appreciate that. The code you've provided did the trick for the most part, all 3 double typed columns are now fine, the only remaining problem is the DateTime column as you've said. I had to add an exception for that column in the EditorRequired event handler, otherwise I would get an exception for trying to compare DateTime with a String, which may have been expected since you've already said this wouldn't work on the DateTime column.

As far as suggestions, I don't really have any except that I would love a way to use RadTextBoxEditor for all columns including DateTime. While I agree that in some cases the other special editors are useful, in some cases just plain string matching works better.

Thanks again,
Baris
0
Jack
Telerik team
answered on 09 Dec 2009, 09:40 AM
Hello Baris,

Yes, I understand. I logged the request and we will discuss it when planning our future versions. If you have any other questions, don't hesitate to ask.

Greetings,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Baris
Top achievements
Rank 1
answered on 14 Dec 2009, 07:11 PM
Hi Jack,

One thing we found out in our testing is if I use a RadTextBoxEditor as the editor for a Double column, we get an unhandled EvaluateException when the user types any illegal character -- this is including a leading '-', which is perfectly legal.

Where/how can I catch these exceptions? Is the only workaround using the (unwanted) standard editor for doubles?

{"Cannot perform '=' operation on System.Double and System.String."}
   at System.Data.BinaryNode.SetTypeMismatchError(Int32 op, Type left, Type right)
   at System.Data.BinaryNode.BinaryCompare(Object vLeft, Object vRight, StorageType resultType, Int32 op)
   at System.Data.BinaryNode.EvalBinaryOp(Int32 op, ExpressionNode left, ExpressionNode right, DataRow row, DataRowVersion version, Int32[] recordNos)
   at System.Data.BinaryNode.Eval(DataRow row, DataRowVersion version)
   at System.Data.UnaryNode.Eval(DataRow row, DataRowVersion version)
   at System.Data.UnaryNode.Eval(DataRow row, DataRowVersion version)
   at System.Data.DataExpression.Invoke(DataRow row, DataRowVersion version)
   at System.Data.Index.AcceptRecord(Int32 record, IFilter filter)
   at System.Data.Index.InitRecords(IFilter filter)
   at System.Data.Index..ctor(DataTable table, Int32[] ndexDesc, IndexField[] indexFields, Comparison`1 comparison, DataViewRowState recordStates, IFilter rowFilter)
   at System.Data.DataTable.GetIndex(IndexField[] indexDesc, DataViewRowState recordStates, IFilter rowFilter)
   at System.Data.DataView.UpdateIndex(Boolean force, Boolean fireEvent)
   at System.Data.DataView.UpdateIndex(Boolean force)
   at System.Data.DataView.SetIndex2(String newSort, DataViewRowState newRowStates, IFilter newRowFilter, Boolean fireEvent)
   at System.Data.DataView.SetIndex(String newSort, DataViewRowState newRowStates, IFilter newRowFilter)
   at System.Data.DataView.set_RowFilter(String value)
   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.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedAction action, Object item, Int32 index)
   at Telerik.WinControls.Data.ObservableCollection`1.InsertItem(Int32 index, T item, Action`1 approvedAction)
   at Telerik.WinControls.Data.ObservableCollection`1.InsertItem(Int32 index, T item)
   at Telerik.WinControls.Data.ItemObservableCollection`1.InsertItem(Int32 index, T item)
   at Telerik.WinControls.Data.FilterExpressionCollection.InsertItem(Int32 index, FilterExpression item)
   at System.Collections.ObjectModel.Collection`1.Add(T item)
   at Telerik.WinControls.Data.Field.set_Filter(FilterExpression value)
   at Telerik.WinControls.UI.GridFilterCellElement.CreateFilter(Object value)
   at Telerik.WinControls.UI.GridFilterCellElement.SetFilterValue(Object value)
   at Telerik.WinControls.UI.GridFilterCellElement.set_Value(Object value)
   at Telerik.WinControls.UI.RadGridView.UpdateFiltering()
   at Telerik.WinControls.UI.RadGridView.OnValueChanged(Object sender, EventArgs e)
   at Telerik.WinControls.UI.RadGridView.CallValueChanged(Object sender, EventArgs e)
   at Telerik.WinControls.UI.BaseGridEditor.OnValueChanged()
   at Telerik.WinControls.UI.RadTextBoxEditor.textBoxItem_TextChanged(Object sender, EventArgs e)
   at Telerik.WinControls.RadItem.OnTextChanged(EventArgs e)
   at Telerik.WinControls.UI.RadTextBoxItem.OnTextChanged(EventArgs e)
   at Telerik.WinControls.RadItem.OnPropertyChanged(RadPropertyChangedEventArgs e)
   at Telerik.WinControls.RadHostItem.OnPropertyChanged(RadPropertyChangedEventArgs e)
   at Telerik.WinControls.UI.RadTextBoxItem.OnPropertyChanged(RadPropertyChangedEventArgs e)
   at Telerik.WinControls.RadObject.RaisePropertyNotifications(RadPropertyValue propVal, Object oldValue, Object newValue)
   at Telerik.WinControls.RadObject.SetValueCore(RadPropertyValue propVal, Object propModifier, Object newValue, ValueSource source)
   at Telerik.WinControls.RadObject.SetValue(RadProperty property, Object value)
   at Telerik.WinControls.UI.RadTextBoxItem.TextBoxControl_TextChanged(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnTextChanged(EventArgs e)
   at System.Windows.Forms.TextBoxBase.OnTextChanged(EventArgs e)
   at System.Windows.Forms.TextBoxBase.WmReflectCommand(Message& m)
   at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
   at System.Windows.Forms.TextBox.WndProc(Message& m)
   at Telerik.WinControls.UI.HostedTextBoxBase.WndProc(Message& message)
   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.SendMessage(HandleRef hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.Control.SendMessage(Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.Control.ReflectMessageInternal(IntPtr hWnd, Message& m)
   at System.Windows.Forms.Control.WmCommand(Message& m)
   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.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.Control.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WmKeyChar(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
   at System.Windows.Forms.TextBox.WndProc(Message& m)
   at Telerik.WinControls.UI.HostedTextBoxBase.WndProc(Message& message)
   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 TradeBlotter.Program.Main() in C:\ctc\psd_nyc\Applications\TradeBlotter\trunk\TradeBlotter\src\Program.cs:line 44
   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()
0
Jack
Telerik team
answered on 15 Dec 2009, 08:38 AM
Hello Baris,

You can avoid this exception by using a customized textbox editor. Please consider the following code snippet:

void radGridView1_EditorRequired(object sender, EditorRequiredEventArgs e)
{
    if (e.EditorType == typeof(RadTextBoxEditor))
    {
        e.EditorType = typeof(CustomTextBoxEditor);
    }
}
 
public class CustomTextBoxEditor: RadTextBoxEditor
{
    public override object Value
    {
        get
        {
            double doubleValue = 0;
            if (base.Value != null)
            {
                double.TryParse(base.Value.ToString(), out doubleValue);
            }
            return doubleValue;
        }
        set
        {
            base.Value = value;
        }
    }
}

If you have any questions, please write back.

Sincerely yours,
Jack
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Baris
Top achievements
Rank 1
Answers by
Jack
Telerik team
Baris
Top achievements
Rank 1
Share this question
or