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

Force specific auto-complete values for RadDateInput

5 Answers 43 Views
Input
This is a migrated thread and some comments may be shown as answers.
Christoffer Rosenqvist
Top achievements
Rank 1
Christoffer Rosenqvist asked on 08 Feb 2010, 03:26 PM
Hi!

Can I force a RadDateInput to use the first month / the first day or the last month / the last day as auto-complete values instead of the month/day och today? E.g. I want to have two inputs where in the user can type "1980" in the first, and I always want that to auto-complete as 1980-01-01 no matter the date. In the second input the user can type "1984" and that should auto-complete as 1984-12-31.

Possible?

From this it also follows that if the user in the second input types "1984-02" the auto-complete should be 1984-02-29, and "1983-02" should be 1983-02-28.

5 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 10 Feb 2010, 10:26 AM
Hi Christoffer,

The described behavior is not supported out-of-the-box, but can be implemented with a couple of Javascript functions. Here is a simple demo, which shows how to set January 1 or December 31 as day and month, if the user enters a year only. Use it as a starting point for any custom autocomplete behaviors that you may need.

<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<script runat="server">
 
</script>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 
<head id="Head1" runat="server">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title>RadControls</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
 
<telerik:RadDateInput ID="RadDateInput1" runat="server" Label="Start">
    <ClientEvents OnValueChanging="autoComplete1" />
</telerik:RadDateInput>
 
<br /><br />
 
<telerik:RadDateInput ID="RadDateInput2" runat="server" Label="End">
    <ClientEvents OnValueChanging="autoComplete2" />
</telerik:RadDateInput>
 
<script type="text/javascript">
 
function autoComplete1(sender, args)
{
    var tbValue = sender.get_textBoxValue();
    if (tbValue.length == 4)
    {
        args.set_cancel(true);
        var newDate = new Date(tbValue, 0, 1);
        window.setTimeout(function(){sender.set_selectedDate(newDate);}, 1);
    }
}
 
function autoComplete2(sender, args)
{
    var tbValue = sender.get_textBoxValue();
    if (tbValue.length == 4)
    {
        args.set_cancel(true);
        var newDate = new Date(tbValue, 11, 31);
        window.setTimeout(function(){sender.set_selectedDate(newDate);}, 1);
    }
}
 
</script>
 
</form>
</body>
</html>


All the best,
Dimo
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Christoffer Rosenqvist
Top achievements
Rank 1
answered on 22 Sep 2010, 01:59 PM
Hi!

I'm using your exact example, but the RadDateInput does not get the new value of the newDate variable. It just gets no value at all and the Input warns me.

What's wrong?
0
Dimo
Telerik team
answered on 22 Sep 2010, 02:25 PM
Hi Christoffer,

The example works as expected on my side. Which RadControls version are you testing with?

Kind regards,
Dimo
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
0
Christoffer Rosenqvist
Top achievements
Rank 1
answered on 23 Sep 2010, 03:12 PM
I'm using version 2010.2.826.35 and I'm running Visual Studio 2008. It doesn't update the textbox with a new value from the newDate variable. When I do an alert(newDate) I can see that the date value is correct, but the textbox doesn't get it.
0
Dimo
Telerik team
answered on 27 Sep 2010, 08:29 AM
Hi Christoffer,

I am afraid I can't see anything wrong with the provided example. Please send us a formal support ticket with a non-working example attached.

Greetings,
Dimo
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
Input
Asked by
Christoffer Rosenqvist
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Christoffer Rosenqvist
Top achievements
Rank 1
Share this question
or