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

Clearing RadDatePicker in a Custom FilteringControl

1 Answer 96 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeff R
Top achievements
Rank 1
Jeff R asked on 26 Jul 2011, 05:32 PM
Hi,

I used something very similar to Telerik's 'Custom Filter Controls' demo: http://demos.telerik.com/silverlight/#GridView/CustomFilterControls

The control works great - however, clicking the "Clear" button does not clear the values in the raddatepicker fields (in the filter gui).  Typically, a Clear button should clear the field values, so that is what I need to implement.  The demo cited simply sets the fields to arbitrary dates within the OnClear method, but that is not an option for me.

I tried using the ClearValue:  this.fromDatePicker.ClearValue(DatePicker.SelectedDateProperty)
but that does not clear the fields.

Is there a method that I am missing?  What is the easiest, most straight forward way to accomplish this?

Thanks in advance - Jeff

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 27 Jul 2011, 03:20 PM
Hello Jeff R,

You may set the two properties FromDate and ToDate to be nullable and clear their values instead of setting the default one as it is in the example. So, what you may try is:

public DateTime? FromDate
        {
            get { return this.fromDatePicker.SelectedDate.GetValueOrDefault(DateTime.MinValue); }
            set { this.fromDatePicker.SelectedDate = value; }
        }
 
public DateTime? ToDate
        {
            get { return this.toDatePicker.SelectedDate.GetValueOrDefault(DateTime.MaxValue); }
            set { this.toDatePicker.SelectedDate = value; }
        }
 
private void OnClear(object sender, RoutedEventArgs e)
        {
            if (this.column.DataControl.FilterDescriptors.Contains(this.compositeFilter))
            {
                this.column.DataControl.FilterDescriptors.Remove(this.compositeFilter);
            }
 
            this.FromDate = null;
            this.ToDate = null;
 
            this.IsActive = false;
        }
  

Regards,
Maya
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
GridView
Asked by
Jeff R
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or