[OPEN] [#1381] [4.1.0] DateMenu issue

  1. #1

    [OPEN] [#1381] [4.1.0] DateMenu issue

    Choosing a new date from the DateMenu, throws a JS exception:

    Unable to get property 'setValue' of undefined or null reference


    Working sample. Original code works fine in Ext.Net 2.5


    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
       <title></title>
    
       <script runat="server">
          public class SomeModel
          {
             public DateTime SelectedDate
             {
                get;
                set;
             }
    
             public DateTime InitialLoadDate
             {
    
                get;
                set;
             }
          }
    
          const string SOME_DATA = "SomeData";
    
          public SomeModel Model
          {
             get
             {
                return Session[ SOME_DATA ] as SomeModel;
             }
          }
    
          protected void Page_Init( object sender, EventArgs e )
          {
             SomeModel aModel = null;
    
             if ( !IsPostBack )
             {
                aModel = Model;
                if ( aModel == null )
                {
                   aModel = new SomeModel();
                   aModel.SelectedDate = aModel.InitialLoadDate = DateTime.Today;
                   Session[ SOME_DATA ] = aModel;
                }
             }
             else if ( X.IsAjaxRequest )
             {
                aModel = Session[ SOME_DATA ] as SomeModel;
             }
          }
    
          protected void Page_Load( object sender, EventArgs e )
          {
             SomeModel aModel = Session[ SOME_DATA ] as SomeModel;
    
             if ( IsPostBack && aModel.InitialLoadDate != DateTime.Today )
             {
                SetDate( DateTime.Today );
                aModel.InitialLoadDate = DateTime.Today;
             }
    
          }
    
          [DirectMethod( Namespace = "Dashboard" )]
          public void SetDate( DateTime aDate )
          {
             Model.SelectedDate = aDate.Date;
             btnDate.DataBind();
          }
       </script>
    </head>
    <body>
       <form id="form1" runat="server">
          <ext:ResourceManager runat="server" ID="testRM" />
    
          <ext:Panel runat="server" Layout="FitLayout" ID="DashboardContainer">
             <TopBar>
                <ext:Toolbar runat="server" ID="toolbarDashboard">
                   <LayoutConfig>
                      <ext:HBoxLayoutConfig Pack="Center" Align="Middle"></ext:HBoxLayoutConfig>
                   </LayoutConfig>
                   <Items>
                      <ext:Button runat="server" Icon="Calendar" Text='<%# Model.SelectedDate.ToShortDateString() %>' ID="btnDate" AutoDataBind="true">
                         <Menu>
                            <ext:DateMenu runat="server" ID="DateSelector">
                               <Picker ID="DatePicker" runat="server" SelectedDate='<%# Model.SelectedDate %>' AutoDataBind="true">
                               </Picker>
                               <Listeners>
                                  <Select Handler="Dashboard.SetDate(date)" Scope="Dashboard">
                                  </Select>
                               </Listeners>
                            </ext:DateMenu>
                         </Menu>
                      </ext:Button>
                   </Items>
                </ext:Toolbar>
             </TopBar>
          </ext:Panel>
    
       </form>
    </body>
    </html>
  2. #2
    Hello Edgar!

    That's odd, thanks for reporting!

    For now, defining PreInit to DateMenu should do. It should look like something like this:

    <ext:DateMenu runat="server" ID="DateSelector">
        <Picker runat="server" ID="DatePickers" SelectedDate='<%# Model.SelectedDate %>' AutoDataBind="true" />
        <PreInit Handler="eval('window.App.' + this.pickerConfig.id + '=this;');" />
        <Listeners>
            <Select Handler="Dashboard.SetDate(date)" Scope="Dashboard">
            </Select>
        </Listeners>
    </ext:DateMenu>
    The script with eval() will allow you to use the same code without having to re-type the picker ID around.

    We have logged this bug under #1381 in our issues tracking service and will update here as soon as we fix this problem!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Thanks FabrÃ*cio! It works.

    [ Just realized you have an evergreen last name. Hope you'll always remain evergreen :) ]
  4. #4
    Hi! Thanks for the feedback and glad it worked!

    I'm just not really sure what an evergreen name means but, if that's a good thing, I will try to keep it evergreen for good!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Murta is the Portuguese/Sardinian name of an evergreen small tree. Well, it's also the name of a drink, but I prefer the first meaning :)
  6. #6
    Oh, alright, it is the Murraya paniculata, very common around here. Had one of these on one of the houses I lived in by childhood! :)
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [FIXED] [#353] [4.3.0] Grid issue
    By RRD in forum Bugs
    Replies: 3
    Last Post: Aug 15, 2017, 11:39 PM
  2. Replies: 2
    Last Post: Aug 15, 2011, 9:49 AM
  3. [CLOSED] hideOnClick in DateMenu is lost...
    By pil0t in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 13, 2010, 12:25 PM
  4. [CLOSED] Set value of datemenu
    By wazige in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Nov 17, 2009, 5:36 AM
  5. [CLOSED] DateMenu in a SplitButton
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Dec 15, 2008, 3:25 PM

Tags for this Thread

Posting Permissions