I have implemented code in environment of asp.net C# to drag and drop from Telerik treeview into Telerik scheduler to create appointment.
I got the problem into only Chrome sometimes when going to schedule any appointment by drag and drop into Telerik scheduler from Telerik treeview.
Error description is as below:
"1176.666697837689 is not a valid value for Int32." Every time decimal value is changing.
Error ExceptionStackTrace is as below:
at System.ComponentModel.BaseNumberConverter.ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at System.ComponentModel.TypeConverter.ConvertFromInvariantString(String text)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.AssignToPropertyOrField(Object propertyValue, Object o, String memberName, JavaScriptSerializer serializer, Boolean throwOnError)
at System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary`2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize(JavaScriptSerializer serializer, String input, Type type, Int32 depthLimit)
at System.Web.Script.Serialization.JavaScriptSerializer.Deserialize[T](String input)
at Telerik.Web.UI.RadScheduler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at Telerik.Web.UI.RadDataBoundControl.System.Web.UI.IPostBackDataHandler.LoadPostData(String postDataKey, NameValueCollection postCollection)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I have used below code to to drag and drop from Telerik treeview to Telerik Scheduler :
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
//<![CDATA[
//Shows whether an Appointment is inserted directry, or the
//the Advanced Insert Form is opened when TreeView node is dropped on the Scheduler.
var directlyInsertAppointment = true;
var selectedAppointment = null;
function nodeDropping(sender, eventArgs) {
var htmlElement = eventArgs.get_htmlElement();
var scheduler = $find('<%= RadScheduler1.ClientID %>');
if (isPartOfSchedulerAppointmentArea(htmlElement)) {
//Gets the TimeSlot where an Appointment is dropped.
var timeSlot = scheduler.get_activeModel().getTimeSlotFromDomElement(htmlElement);
var startTime = timeSlot.get_startTime();
var startTimes = startTime.toDateString() + " " + startTime.toTimeString();
document.getElementById('<%= hdnScheduledStartDateTime.ClientID %>').value = startTimes;
//Gets all the data needed for the an Appointment, from the TreeView node.
var node = eventArgs.get_sourceNode();
var text = node.get_text();
document.getElementById('<%= hdnSessionSubject.ClientID%>').value = text;
var nodeVal = node.get_value();
document.getElementById('<%= hdnPTSessionsClientManagementId.ClientID %>').value = nodeVal;
var attributes = node.get_attributes();
var PTSessionMgmtID = attributes.getAttribute("PTSessionsManagementId");
document.getElementById('<%= hdnPTSessionsManagementId.ClientID %>').value = PTSessionMgmtID;
var SessionTypeId = attributes.getAttribute("SessionTypeId");
document.getElementById('<%= hdnSessionTypeId.ClientID %>').value = SessionTypeId;
var duration = attributes.getAttribute("Duration");
var endTime = new Date(startTime);
endTime.setMinutes(parseInt(endTime.getMinutes()) + parseInt(duration));
var endTimes = endTime.toDateString() + " " + endTime.toTimeString();
document.getElementById('<%= hdnScheduledEndDateTime.ClientID %>').value = endTimes;
var parentValue = node.get_parent().get_value();
var category = scheduler.get_resources().getResourceByTypeAndKey("Category", parentValue);
//New appointment is created. The start/end time, subject and category are set.
var newAppointment = new Telerik.Web.UI.SchedulerAppointment();
newAppointment.set_start(startTime);
newAppointment.set_end(endTime);
newAppointment.set_subject(text);
if (category != null) {
newAppointment.get_resources().add(category);
}
//Checks for the user's choice of the method for inserting Appointments.
if (directlyInsertAppointment) {
scheduler.insertAppointment(newAppointment);
} else {
//If Advanced Form is opened, the information from the TreeVew node is stored in a hidden input.
var appointmentInfo = { subject: text, duration: duration, category: category };
var appointmentInfoSerialized = Sys.Serialization.JavaScriptSerializer.serialize(appointmentInfo);
$get("<%=HiddenInputAppointmentInfo.ClientID%>").value = appointmentInfoSerialized;
scheduler.showInsertFormAt(timeSlot);
}
}
else {
//The node was dropped elsewhere on the document.
eventArgs.set_cancel(true);
}
}
</script>
This functionality is working properly on local server but somehow it's not working on client server, sometimes in Chrome browser.
Apparently it's fixed in newer versions of Telerik, but caused by Google Chrome now sending fractional pixel values for scroll positions:
Some workarounds are listed here: https://www.telerik.com/forums/system-formatexception-78e82e51af27#KkKRUtkEq0ST4A09XY_eZQ