I'm trying to use a raddatepicker in a radgrid where the user can only select the Month and Year, rather than the date from the RadCalendar.
I have implemented this once before using the javascript from the Code Library at the link below and it has worked fine.
Now I am trying to apply it to a raddatepicker that is inside of an EditForm and it will not work.
I can pass in the RadDatePicker's client ID and when I debug I see that it finds the object, but it continually tells me that the object does not contain those methods or properties.
The applicable code is below. Please let me know if you can help me or if you need any further information.
<script type="text/javascript"> |
//override the onload event handler to change the picker after the page is loaded |
window.onload = function () |
{ |
window.setTimeout(function() {SetCalendarTable();},200) |
} |
function SetCalendarTable() |
{ |
var picker = "ctl00_RadPanel_ForecastGrid_ctl00_ctl02_ctl02_rdpForecastStartDate"; |
var calendar = picker.get_calendar(); |
var fastNavigation = calendar._getFastNavigation(); |
$clearHandlers(picker.get_popupButton()); |
$addHandler(picker.get_popupButton(), "click", function() |
{ |
//debugger; |
var textbox = picker.get_textBox(); |
//adjust where to show the popup table |
var x, y; |
var adjustElement = textbox; |
if (textbox.style.display == "none") |
adjustElement = picker.get_popupImage(); |
var pos = picker.getElementPosition(adjustElement); |
x = pos.x; |
y = pos.y + adjustElement.offsetHeight; |
var e = { |
clientX : x, |
clientY : y |
}; |
//synchronize the input date if set with the picker one |
var date = picker.get_selectedDate(); |
if(date) |
{ |
calendar.FocusedDate[0] = date.getFullYear(); |
calendar.FocusedDate[1] = date.getMonth() + 1; |
} |
$get(calendar._titleID).onclick(e); |
}); |
fastNavigation.OnOK = |
function() |
{ |
var date = new Date(fastNavigation.Year, fastNavigation.Month, 1); |
picker.get_dateInput().SetDate(date); |
fastNavigation.Popup.Hide(); |
} |
fastNavigation.OnToday = |
function() |
{ |
var date = new Date(); |
picker.get_dateInput().SetDate(date); |
fastNavigation.Popup.Hide(); |
} |
} |
</script> |
<telerik:RadGrid ID="ForecastGrid" |
AllowPaging="True" |
AllowSorting="True" |
EnableEmbeddedSkins="false" |
GridLines="None" |
OnInsertCommand="ForecastGrid_InsertCommand" |
OnItemCommand="ForecastGrid_ItemCommand" |
OnItemCreated="ForecastGrid_ItemCreated" |
OnItemDataBound="ForecastGrid_ItemDataBound" |
OnNeedDataSource="ForecastGrid_NeedDataSource" |
OnUpdateCommand="ForecastGrid_UpdateCommand" |
PageSize="15" |
runat="server" |
ShowFooter = "true" |
Skin="AO" |
Visible = "true"> |
<MasterTableView CommandItemDisplay="Bottom" AutoGenerateColumns = "false" DataKeyNames="ForecastId"> |
<EditFormSettings EditFormType = "Template"> |
<FormTemplate> |
<div style="padding: 10px;"> |
<div class="text"> |
Click the <b>Save</b> button to save your changes.</div> |
<div> |
<asp:Label Visible="false" ID="ErrorLabel" runat="server" /></div> |
<div style="clear: both;"> |
</div> |
<div class="validation-summary"> |
<asp:ValidationSummary HeaderText="Changes not saved." DisplayMode="SingleParagraph" |
ID="ValidationSummary1" runat="server"></asp:ValidationSummary> |
</div> |
<div style="clear: both;"> |
</div> |
<div> |
<asp:Label ID="ForecastIdLabel" Visible="false" runat="server" Text='<%# Bind("ForecastId") %>'></asp:Label></div> |
<div> |
<div> |
<asp:Label ID="IsActiveLabel" Visible="false" runat="server" Text='<%# Bind("IsActive") %>'></asp:Label> |
</div> |
<div class="label-short" style="float: left; padding-bottom: 5px; width:150px;"> |
Forecast Name:</div> |
<div style="padding-bottom: 5px;"> |
<Telerik:RadTextBox ID="ForecastName" runat="server" Skin="AO" EnableEmbeddedSkins="false" |
Text='<%# Bind("ForecastName") %>' Width="240" MaxLength="50"> |
</Telerik:RadTextBox> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ForecastName" |
ErrorMessage="Forecast Name is required.">*</asp:RequiredFieldValidator> |
</div> |
<div style="clear: both;"> |
</div> |
<div class="label-short" style="float: left; padding-bottom: 5px; width:150px;"> |
Forecast Start Date:</div> |
<div style="padding-bottom: 5px;"> |
<telerik:RadDatePicker ID="rdpForecastStartDate" DateInput-DateFormat="MMMM, yyyy" runat="server" |
AutoPostBack="false" ToolTip="Month" Width="130px" CssClass="date-picker" Skin="AO" |
EnableEmbeddedSkins="false"> |
</telerik:RadDatePicker> |
<%--<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="rdpForecastStartDate" |
ErrorMessage="Forecast Start Date is required.">*</asp:RequiredFieldValidator>--%> |
</div> |
<div style="clear: both;"> |
</div> |
<div class="label-short" style="float: left; padding-bottom: 5px; width:150px;"> |
Forecast Length:</div> |
<div style="padding-bottom: 5px;"> |
<telerik:RadComboBox ID="rcbForecastLength" runat="server" ZIndex="7020" Skin="AO" EnableEmbeddedSkins="false" Width="243"> |
</telerik:RadComboBox> |
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="rcbForecastLength" |
ErrorMessage="Forecast Length is required.">*</asp:RequiredFieldValidator> |
</div> |
<div style="clear: both;"> |
</div> |
<div class="label-short" style="float: left; padding-bottom: 5px; width:150px;"> |
Is Active:</div> |
<div style="float: left; padding-bottom: 5px;"> |
<asp:CheckBox ID="IsActiveCheckbox" runat="server"></asp:CheckBox> |
</div> |
<div style="clear: both;"> |
</div> |
<div> |
<asp:Button ID="UpdateButton" CssClass="button" runat="server" Text="Save" CommandName="Update" /> |
<asp:Button ID="InsertButton" CssClass="button" runat="server" Text="Save" CommandName="PerformInsert" /> |
<asp:Button ID="CancelButton" CssClass="button" runat="server" Text="Cancel" CommandName="Cancel" |
CausesValidation="false" /> |
</div> |
</div> |
</FormTemplate> |
</EditFormSettings> |
</MasterTableView> |
</telerik:RadGrid> |