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

Automatically setting a date field to be today's date

3 Answers 263 Views
Filter
This is a migrated thread and some comments may be shown as answers.
Danny
Top achievements
Rank 1
Danny asked on 11 Aug 2014, 09:29 AM
Hi,

We use RadFilter to create a number of reports, some of which filter by date. In some instances we don't want to manually select a date but to simply set it to be today's date so that the report can give us all of today's appointments, for example.

Rather than manually selecting a date in a date fields, is it possible to simply input something like 'today' so that every time we load the report, it automatically sets the date for that field to be today?

Thanks

Tim

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 11 Aug 2014, 10:13 AM
Hi timmy,

Please try the below sample code snippet to set the Default date for the RadFilter.

ASPX:
<telerik:RadFilter runat="server" ID="RadFilter1">
    <FieldEditors>
        <telerik:RadFilterDateFieldEditor FieldName="OrderDate" PickerType="DatePicker" />
    </FieldEditors>
</telerik:RadFilter>

C#:
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        this.CreateDefaultFilterExpressions();
    }
}
private void CreateDefaultFilterExpressions()
{
    var orderDateExpression = new RadFilterEqualToFilterExpression<DateTime>("OrderDate");
    orderDateExpression.Value = DateTime.Now.Date;
    RadFilter1.RootGroup.AddExpression(orderDateExpression);
}

Hope this will helps you.
Thanks,
Shinu.
0
Danny
Top achievements
Rank 1
answered on 11 Aug 2014, 10:28 AM
Shinu,

Thanks for your prompt reply.

That would do it but the end user creates their own reports using RadFilter and so it isn't possible to know in advance which date field they want to set to being 'today'.

For the future it maybe useful to have the option to set a datetime field to be 'today' directly on the control so whenever it loads it automatically applies today's date.

Regards

Tim 
0
Maria Ilieva
Telerik team
answered on 14 Aug 2014, 08:12 AM
Hello Timmy,

Thank you for your suggestion.

Adding such a built in functionality could be of a help for the users that are trying to implement this scenarios.
Therefore I would suggests you to log it in our feedback portal below, so that our dev team could further discuss its possible implementation.
Ideas & Feedback Portal

Regards,
Maria Ilieva
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.

 
Tags
Filter
Asked by
Danny
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Danny
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or