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

Remove validation from GridView FilterRow

4 Answers 154 Views
GridView
This is a migrated thread and some comments may be shown as answers.
ITC
Top achievements
Rank 1
ITC asked on 27 Nov 2014, 10:20 AM
Hi,

I am using a RadGridView inside of a UserControl with dynamic content (with MVVM).
The filtering mode of the Grid is set to 'FilterRow'.

Is it possible to remove validation from the TextBoxes of the filterrow?

We would like to use mathematical operators inside the TextBoxes to filter the DataGrid.
Example: If You type '>3' into the column filter of an 'AGE' column ('AGE' is of type 'int') I would like to perform in code behind the 'isGreaterThan' filter method.
The filtering in code behind won't be a problem, but the validation for this column is not accepting '>' because it is not a numeric value.

Can you provide an approach/code samples how to do this?

Thanks in advance
Heiko

4 Answers, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 01 Dec 2014, 01:22 PM
Hello Heiko,

Generally, the TextBox used for entering the filtering criteria cannot prevent the user from entering invalid characters. If the string that was entered was not in the correct format(i.e. the string -  ">", since it expects an integer) there should be a validation error and the text box should be surrounded with red border. You can easily replace the stock TextBox with your advanced editor by following the Create a Custom Field Filter Editor / Customize the Default Field Filter Editor help article.

Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
ITC
Top achievements
Rank 1
answered on 03 Dec 2014, 11:15 AM
Hi,

Thank You for Your reply.

But I am fine with the Field Filter Editor provided by the 'FilterRow' of the RadGridView. I only would like to disable/remove the validation.
I can access the Editor in the FieldFilterEditorCreated(object sender, EditorCreatedEventArgs e) event with e.Editor but there doesn't seem to be an event or attribute which allows me to manipulate the validation of the input field.

Is it possible to only remove validation without creating a Custom Field Filter Editor?

Regards Heiko
0
Accepted
Yoan
Telerik team
answered on 08 Dec 2014, 08:43 AM
Hello Heiko,

If you want to remove the validation border, you can set the following style for the editor:
<Style TargetType="TextBox">
    <Setter Property="Validation.ErrorTemplate" Value="{x:Null}"/>
</Style>

However, this will not help you for filter the items. It will remove the red border, but you need to implement your own filtering logic. I think that you will find this GitHub example useful.

I hope this information helps.

Regards,
Yoan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
ITC
Top achievements
Rank 1
answered on 09 Dec 2014, 08:24 AM
Thanks, that is what I wanted.

The filtering is performed in code behind, but because I want to accept logical operators (>, <, =, ...) in all input fields I needed the validation to be turned off.

Thank You!

Tags
GridView
Asked by
ITC
Top achievements
Rank 1
Answers by
Yoan
Telerik team
ITC
Top achievements
Rank 1
Share this question
or