Error handling grid filter

2 posts, 0 answers
  1. Graeme
    Graeme avatar
    5 posts
    Member since:
    Jun 2012

    Posted 03 Nov 2015 Link to this post

    I have a radgrid set up to allow filtering on date columns which appears to be working fine.

    However I can't work out how to deal with invalid input. For example  entering text instead of a date crashes the page.

    Can anyone point me in the right direction of how I can either trap the error (eg where to put a try/catch block) and/or how I can apply an input mask?

  2. Maria Ilieva
    Maria Ilieva avatar
    4017 posts

    Posted 06 Nov 2015 Link to this post


    You can access the picker filter control and on its OnError client event fire a custom message for example:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
        if (e.Item is GridFilteringItem)
            GridFilteringItem filterItem = e.Item as GridFilteringItem;
            foreach (GridColumn column in RadGrid1.MasterTableView.RenderColumns)
                if (column is GridDateTimeColumn && (column as GridDateTimeColumn).AllowFiltering)
                    RadDatePicker picker = filterItem[column.UniqueName].Controls[0] as RadDatePicker;
                    picker.DateInput.ClientEvents.OnError = "customError";

                function customError() {
                    alert("The date should be in the following format: MM/dd/yyyy");

    Maria Ilieva
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top