Remove month name listing from the Fast Navigation popup of DateTimePicker

6 posts, 0 answers
  1. Sree
    Sree avatar
    13 posts
    Member since:
    May 2009

    Posted 08 Mar 2010 Link to this post

    Hi
    I have customized the date time picker to a Month Year picker with the help of the following code library
    http://www.telerik.com/community/code-library/aspnet-ajax/calendar/month-year-picker.aspx
    In this code sample when we click on the Calendar popup button of the DateTimePicker the Fast Navigation popup with the Month and Year listing is shown instead of the Calendar popup.Now I want to remove the month listing from this fast navigation popup to convert the DateTimepicker to an Year picker.How can I achieve this requirement.
  2. Dimo
    Admin
    Dimo avatar
    8452 posts

    Posted 10 Mar 2010 Link to this post

    Hi Sree,

    The easiest way to hide the month cells is to use CSS. Here is a simple demo. You can construct the CSS rule string programmatically as well.


    <%@ Page Language="C#" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     
    <head runat="server">
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <title>RadControls</title>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <style type="text/css">
     
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Jan,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Feb,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Mar,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Apr,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_May,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Jun,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Jul,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Aug,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Sep,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Oct,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Nov,
    #<%= RadDatePicker1.ClientID %>_calendar_FastNavPopup #rcMView_Dec
    {
        display:none;
    }
     
    </style>
    </telerik:RadCodeBlock>
    </head>
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
     
    <telerik:RadDatePicker ID="RadDatePicker1" runat="server" />
     
    </form>
    </body>
    </html>


    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.
  3. Sree
    Sree avatar
    13 posts
    Member since:
    May 2009

    Posted 10 Mar 2010 Link to this post

    Thank you very much for the help .Now I can hide the month names .But now another issue. I  have placed this DateTimePicker in a user control and when I place this user control (.acx)in one of my form I am getting a script error.When I debug through the javascript the bug came in  'setCalendarTable()' method .I will paste the debug window code here.



    <script type="text/javascript">
                //override the onload event handler to change the picker after the page is loaded
                Sys.Application.add_load(setCalendarTable);

                function setCalendarTable()
                {
                   
                    
                   // alert("ctl01_ContentPlaceHolder1_MonthYearPicker1_dpMY");
                    var picker = $find("ctl01_ContentPlaceHolder1_MonthYearPicker1_dpMY");
                    var calendar = picker.get_calendar();

                    var fastNavigation = calendar._getFastNavigation();



    The problem is getting the control id

    var picker = $find("ctl01_ContentPlaceHolder1_MonthYearPicker1_dpMY");

      here I am getting  the 'picker' variable as  null  and in next line(picker.get_calendar();) the error occurs.

    My actual code from the page is given below

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="MonthYearPicker.ascx.cs" Inherits="UserControls_MonthYearPicker" %>

    <telerik:RadCodeBlock ID="cbMonthYearPicker" runat="server">

     <script type="text/javascript">
                //override the onload event handler to change the picker after the page is loaded
                Sys.Application.add_load(setCalendarTable);

                function setCalendarTable()
                {
                              
                 
                    var picker = $find("<%= dpMY.ClientID %>");
                    var calendar = picker.get_calendar();
                    var fastNavigation = calendar._getFastNavigation();

  4. Dimo
    Admin
    Dimo avatar
    8452 posts

    Posted 12 Mar 2010 Link to this post

    Hi Sree,

    I can't reproduce this problem on my side. Here is my test website. Please compare with your implementation.

    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.
  5. Sree
    Sree avatar
    13 posts
    Member since:
    May 2009

    Posted 13 Mar 2010 Link to this post

    Hi

    I am still facing the same problem.I have placed the DateTimePicker inside a multiview and when I try to locate the DateTime Picker using the find function() {var picker = $find("<%= dpMY.ClientID %>");} the error occurs.I have set the activeview of the multiview=1,I which the control "dpMY"(DateTimePicker) doesnot exists.It is actually in first view(activeview=0).Is there any way to check the activeview index of a Multiview in javascript??
  6. Dimo
    Admin
    Dimo avatar
    8452 posts

    Posted 15 Mar 2010 Link to this post

    Hello Sree,

    Yes, you can use the RadMultiPage API to check the selected page view:

    http://www.telerik.com/help/aspnet-ajax/tab_mutlipage_client_object.html

    If you need further assistance with the picker client reference problem, we will need a runnable demo, similar to the one I have provided previously.

    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.
Back to Top