2017-05-08 154 views
0

我正在尝试实施Daypilot lite日历。到目前为止,它是好的,但我似乎碰到了一些障碍。DayPilot日历创建事件

我想在calander中创建一个新事件,但我似乎无法将除事件开始和结束之外的任何信息传递给daypilot模式。

JavaScript runtime error: 'team' is undefined 

以上这行是我收到的错误。 在我的aspx页面的控制代码:

<h1>Welcome <asp:Label ID="lblTeam" runat="server"></asp:Label></h1> 
     <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" AppendDataBoundItems="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"> 
      <asp:ListItem Selected="True" Value="0">Select a pitch</asp:ListItem> 
     </asp:DropDownList> 
     <DayPilot:DayPilotCalendar 
      ID="DayPilotCalendar1" 
      runat="server" 
      DataStartField="sess_start" 
      ShowEventStartEnd="true" 
      DataEndField="sess_end" 
      DataTextField="team" 
      DataIdField="BookingId" 
      ClientObjectName="dpc1" 
      TimeRangeSelectedHandling="JavaScript" 
      TimeRangeSelectedJavaScript="timeRangeSelected(start, end, team, pitch)" 
      OnCommand="DayPilotCalendar1_Command" 
      NonBusinessBackColor="Black" 
      HeightSpec="BusinessHoursNoScroll" 
      BusinessEndsHour="20" 
      OnEventMove="DayPilotCalendar1_EventMove" 
      EventMoveHandling="CallBack" 
      /> 

我的JavaScript代码,将数据发送到模式:

function timeRangeSelected(start, end, team, pitch) { 
     team = document.getElementById('<%= lblTeam.ClientID %>').innerText; 
     var pitchSel = document.getElementById('<%= DropDownList1.ClientID %>'); 
     pitch = pitchSel.options[pitchSel.selectedIndex].value; 
     var modal = new DayPilot.Modal(); 
     modal.top = 60; 
     modal.width = 300; 
     modal.opacity = 70; 
     modal.border = "10px solid #d0d0d0"; 
     modal.closed = function() { 
      if (this.result == "OK") { 
       dpc1.commandCallBack('refresh'); 
      } 
      dpc1.clearSelection(); 
     }; 
     modal.showUrl("New.aspx?start=" + start.toStringSortable() + "&end=" + end.toStringSortable() + "&r=" + team + "&pitch=" + pitch); 
    } 

我需要能够传递的不仅仅是开始和结束的模态。 正如我所提到的,我不太确定这里发生了什么,所以任何可以提供的指导将不胜感激。

回答

0

我弄清楚我做错了什么,所以我想我会分享它,以防其他人有同样的麻烦。

以下是我更新的JavaScript代码。基本上我的问题是关于我在哪里宣布用于存储数据的变量传递给模态。当他们需要在函数的范围之外声明时,我已经将它们放置在函数中。愚蠢的错误,但容易做出。

var team = document.getElementById('<%= lblTeam.ClientID %>').innerText; 
    var pitchSel = document.getElementById('<%= DropDownList1.ClientID %>'); 
    var pitch = pitchSel.options[pitchSel.selectedIndex].value; 

    function timeRangeSelected(start, end, team, pitch) { 
     var modal = new DayPilot.Modal(); 
     modal.top = 60; 
     modal.width = 300; 
     modal.opacity = 70; 
     modal.border = "10px solid #d0d0d0"; 
     modal.closed = function() { 
      if (this.result == "OK") { 
       dpc1.commandCallBack('refresh'); 
      } 
      dpc1.clearSelection(); 
     }; 
     modal.showUrl("New.aspx?start=" + start.toStringSortable() + "&end=" + end.toStringSortable() + "&r=" + team + "&pitch=" + pitch); 
    } 

我希望这可以帮助未来的人。甚至可能是我,你永远不知道!