Automatically setting a date field to be today's date

4 posts, 0 answers
  1. timmy
    timmy avatar
    38 posts
    Member since:
    Dec 2006

    Posted 11 Aug 2014 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 11 Aug 2014 in reply to timmy Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. timmy
    timmy avatar
    38 posts
    Member since:
    Dec 2006

    Posted 11 Aug 2014 in reply to Shinu Link to this post

    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 
  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 14 Aug 2014 Link to this post

    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.

     
Back to Top