Remove validation from GridView FilterRow

5 posts, 1 answers
  1. Heiko
    Heiko avatar
    20 posts
    Member since:
    Nov 2013

    Posted 27 Nov 2014 Link to this post

    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
  2. Yoan
    Admin
    Yoan avatar
    1190 posts

    Posted 01 Dec 2014 Link to this post

    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.

     
  3. Heiko
    Heiko avatar
    20 posts
    Member since:
    Nov 2013

    Posted 03 Dec 2014 in reply to Yoan Link to this post

    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
  4. Answer
    Yoan
    Admin
    Yoan avatar
    1190 posts

    Posted 08 Dec 2014 Link to this post

    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.

     
  5. Heiko
    Heiko avatar
    20 posts
    Member since:
    Nov 2013

    Posted 09 Dec 2014 in reply to Yoan Link to this post

    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!

Back to Top