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

Date Time Range

7 Answers 204 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Smiely
Top achievements
Rank 1
Smiely asked on 14 Dec 2010, 07:08 PM
I need to select data FROM Date and Time TO Date and Time. Date Range is working but how to add Time to that ? I am doing it in aspx page. Can anybody send me any example ?

7 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Dec 2010, 01:04 PM
Hello,


Are you referring the code library "Date Range selector" ?
If so, you can extent the funtionality by adding TimePickers in ItemTemplate, for selecting From and To times. And set the combo text based on that TimePicker values.

Let me know if you need further assistance in this.

Thanks,
Princy.
0
Smiely
Top achievements
Rank 1
answered on 15 Dec 2010, 03:34 PM
Thanks for replying Princy. Good example.

Right now I am following http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx example(OrderDate Range). Instead of RadDatePicker, I want to use RadDateTimePicker. So wondering how to use time with date in the functions...

<telerik:GridBoundColumn UniqueName="OrderDate" DataField="OrderDate" HeaderText="Order date" DataFormatString="{0:D}" HeaderStyle-Width="350px">
  
<FilterTemplate>From
<telerik:RadDatePicker ID="FromOrderDatePicker" runat="server" Width="85px" ClientEvents-OnDateSelected="FromDateSelected" MinDate="07-04-1996" MaxDate="05-06-1998" FocusedDate="07-04-1996" DbSelectedDate='<%# startDate %>' />
to
<telerik:RadDatePicker ID="ToOrderDatePicker" runat="server" Width="85px" ClientEvents-OnDateSelected="ToDateSelected" MinDate="07-04-1996" MaxDate="05-06-1998" FocusedDate="05-06-1998" DbSelectedDate='<%# endDate %>' />
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
function FromDateSelected(sender,args) {
    var tableView=$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
    var ToPicker =$find('<%# ((GridItem)Container).FindControl("ToOrderDatePicker").ClientID %>');
                                          
    var fromDate = FormatSelectedDate(sender);
    var toDate = FormatSelectedDate(ToPicker);
                                          
    tableView.filter("OrderDate", fromDate + " " + toDate, "Between"); 
}
                                      
function ToDateSelected(sender,args) {
     var tableView=$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
     var FromPicker =$find('<%# ((GridItem)Container).FindControl("FromOrderDatePicker").ClientID %>');
                                          
     var fromDate = FormatSelectedDate(FromPicker);
     var toDate = FormatSelectedDat(sender);                                                                                   tableView.filter("OrderDate", fromDate + " " + toDate, "Between"); 
}
                                      
function FormatSelectedDate(picker){
     var date = picker.get_selectedDate();
     var dateInput = picker.get_dateInput();
     var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());
                                          
     return formattedDate;
}
</script>
</telerik:RadScriptBlock>
</FilterTemplate>
</telerik:GridBoundColumn>
0
Smiely
Top achievements
Rank 1
answered on 16 Dec 2010, 10:14 PM
Princy .... Telerik ..... anybody...... ???
0
Smiely
Top achievements
Rank 1
answered on 17 Dec 2010, 05:42 PM
And my code behind is....

protected DateTime? startDate
        {
            set
            {
                ViewState["strD"] = value;
            }
            get
            {
                if (ViewState["strD"] != null)
                    return (DateTime)ViewState["strD"];
                else
                    return new DateTime(2010, 12, 13);
            }
        }
        protected DateTime? endDate
        {
            set
            {
                ViewState["endD"] = value;
            }
            get
            {
                if (ViewState["endD"] != null)
                    return (DateTime)ViewState["endD"];
                else
                    return new DateTime(2010, 12, 15);
            }
        }
Please help.............
0
Iana Tsolova
Telerik team
answered on 20 Dec 2010, 02:12 PM
Hi Smiely,

Can you elaborate a bit more on the issue you are facing with the RadDateTimePicker controls?
In the preceding client-side methods the fromDate and toDate variables should be filled with the full date.

All the best,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Smiely
Top achievements
Rank 1
answered on 20 Dec 2010, 05:11 PM
Thanks for replying lana. Exactly ......client-side methods the fromDate and toDate variables should be filled with the full date.
var formattedDate = dateInput.get_dateFormatInfo().FormatDate(date, dateInput.get_displayDateFormat());

This is only date not dateTime. How do I get it there?

I want to display a data from 12/13/2010 4.00 PM to 12/14/2010 10.00 AM.

Please help

Thanks
0
Iana Tsolova
Telerik team
answered on 23 Dec 2010, 12:13 PM
Hi Smiely,

You are right. However getting the selected date of the RadDateTimePicker would return the full date with the time. But to filter the grid with between filter function in this case you will need to handle the filtering manually instead of using the built-in command. Because when the filter function is between you would have additional intervals in the filter expression which cannot be handled by the grid. It expects:

string interval string
 
Please excuse us for the inconvenience.

Best wishes,
Iana
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Calendar
Asked by
Smiely
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Smiely
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or