RadDateInput MMM yyyy issue

3 posts, 0 answers
  1. Chris
    Chris avatar
    2 posts
    Member since:
    Sep 2011

    Posted 30 Sep 2011 Link to this post

    I have searched these forums and haven't found a solution or mention of this yet, but if it's out there, feel free to point me in that direction.

    Using Telerik.Web.UI, v.2011.2.915.40, .NET 4, and ASP.NET/C#, in Visual Studio 2010.

    I have a RadDateInput and would like to use the MMM yyyy date format, and use mouse keys to change the date.  This is the way the RadDateInput is configured:
    <telerik:RadDateInput runat="server" ID="rdiDate" DateFormat="MMM yyyy" DisplayDateFormat="MMM yyyy">
        <IncrementSettings InterceptMouseWheel="false" InterceptArrowKeys="true" />
    </telerik:RadDateInput>

    However, on dates such as Sept. 30, 2011 when the day number (30th) is greater than the days in another month (for example, February 2011 only goes up to 28 days) then you can't use the mouse keys to change to or past that month.  I have tried using the server side OnTextChanged for the RadDateInput to manually set the day to the 1st of the month at that time, but that didn't work.  Setting an initial value in the RadDateInput using the current date and changing the day to the 1st also did not work for me.  I've also tried using javascript on the client OnValueChanging event to re-enter the value with the day of 01, but that didn't work either.  The javascript solution I tried:
    function changeDate(sender, args) {
        var tbVal = sender.get_textBoxValue();
        if (!(document.getElementById('<%= hdnDate.ClientID %>').value == tbVal)) {
            var month = tbVal.substr(0, 3);
            var year = tbVal.substr(4, 4);
            var newDate = new Date(Date.parse(month + " 01, " + year));
            document.getElementById('<%= hdnDate.ClientID %>').value = month + " " + year;
            window.setTimeout(function () { sender.set_selectedDate(newDate); }, 1);
        }
    }
    <telerik:RadDateInput runat="server" ID="rdiDate" DateFormat="MMM yyyy" DisplayDateFormat="MMM yyyy">
         <ClientEvents OnValueChanging="changeDate" />
         <IncrementSettings InterceptMouseWheel="false" InterceptArrowKeys="true" />
    </telerik:RadDateInput>
    <input runat="server" type="hidden" value="" id="hdnDate" />

    Is there something I'm missing? or is this an issue with the RadDateInput control itself?
  2. Vasil
    Admin
    Vasil avatar
    1547 posts

    Posted 05 Oct 2011 Link to this post

    Hello Chris,

    It seems to be a bug in the DateInput. I have logged this and we will fix this soon. I believe you are the first one who report this issue. Thank you for the detailed explanations and for sharing your discoveries, I am updating your Telerik Points.
    Currently there is no workaround for the problem, but I will write here if I got something out.

    All the best,
    Vasil
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Chris
    Chris avatar
    2 posts
    Member since:
    Sep 2011

    Posted 05 Oct 2011 Link to this post

    Thanks for the response

    If it helps anyone else, currently what we are doing is using the DateFormat="MMM 01 yyyy" and DisplayDateFormat="MMM yyyy".  Not ideal, but it does get around the bug.
Back to Top