This is a migrated thread and some comments may be shown as answers.
script error in drag and drop from radgrid to radscheduler
5 Answers 69 Views
This is a migrated thread and some comments may be shown as answers.
utchi
Top achievements
Rank 1
utchi asked on 28 Nov 2009, 01:36 PM
Hi,

I have a problem when drag and drop from radgrid to radscheduler.

I am using master and content page for my process, in that content page i am having following code for drag & drop. 

function rowDropping(sender, eventArgs)

 

{

 

debugger;

 

 

// Fired when the user drops a grid row

 

 

var htmlElement = eventArgs.get_destinationHtmlElement();

 

 

var scheduler = $find('ctl00_Content_RadScheduler1');

 

 

debugger;

 

 

 

if (isPartOfSchedulerAppointmentArea(htmlElement))

 

{

 

// The row was dropped over the scheduler appointment area

 

 

// Find the exact time slot and save its unique index in the hidden field

 

 

var timeSlot = scheduler._activeModel.getTimeSlotFromDomElement(htmlElement);

 

$get(

"ctl00_Content_TargetSlotHiddenField").value = timeSlot.get_index();

 

 

 

// The HTML needs to be set in order for the postback to execute normally

 

eventArgs.set_destinationHtmlElement(

"ctl00_Content_TargetSlotHiddenField");

 

 

debugger;

 

 

}

 

else

 

{

 

// The node was dropped elsewhere on the document

 

eventArgs.set_cancel(

true);

 

}

}


it showing the error on the this line 'var timeSlot = scheduler._activeModel.getTimeSlotFromDomElement(htmlElement);'.

Please find scrren shot for that error message.

How to overcome this.

Thanks in Advance ; ).

Regards
Maha



5 Answers, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 30 Nov 2009, 12:23 PM
Hi utchi,

Please, try using scheduler.get_activeModel() instead of scheduler._activeModel and let us know if this helps.


Greetings,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
utchi
Top achievements
Rank 1
answered on 30 Nov 2009, 01:13 PM
Hi Peter,

Thanks for your suggestion, but doesn't work.

Please find the screenshot attached and code mentioned below.

function

 

rowDropping(sender, eventArgs)

 

{

 

debugger;

 

 

// Fired when the user drops a grid row

 

 

var htmlElement = eventArgs.get_destinationHtmlElement();

 

 

var scheduler = $find('ctl00_Content_RadScheduler1');

 

 

debugger;

 

 

 

if (isPartOfSchedulerAppointmentArea(htmlElement))

 

{

 

// The row was dropped over the scheduler appointment area

 

 

// Find the exact time slot and save its unique index in the hidden field

 

 

var timeSlot = scheduler.get_activeModel.getTimeSlotFromDomElement(htmlElement);

 

$get(

"ctl00_Content_TargetSlotHiddenField").value = timeSlot.get_index();

 

 

 

// The HTML needs to be set in order for the postback to execute normally

 

eventArgs.set_destinationHtmlElement(

"ctl00_Content_TargetSlotHiddenField");

 

 

debugger;

 

 

}

 

else

 

{

 

// The node was dropped elsewhere on the document

 

eventArgs.set_cancel(

true);

 

}

}



how to resolve it. Thanks in advance.

Regards
Utchimahali.N
0
Peter
Telerik team
answered on 03 Dec 2009, 02:34 PM
Hi utchi,

We are not sure why you keep getting this error. It would be best if you can isolate the problem in a simple working demo and send it to us for further testing via a support ticket.


Regards,
Peter
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Accepted
Joe
Top achievements
Rank 1
answered on 03 Dec 2009, 06:48 PM
Hi,

I had the same problem. I found that my javascript call to find the scheduler was not using the proper ClientID. In my case I was declaring and adding the scheduler to the page dynamically. So what I had to do was first declare the control, add it to the controls collection, then call the .ClientID property and add it to the javascript code. I am adding my javascript using RegisterClientScriptBlock during the On_Init phase.

Here is a small code sample. Hope it helps.

Page.ClientScript.RegisterClientScriptBlock(typeof(MyProjectType), "script", AddProjectScripts()); 
 
 private string AddProjectScripts() 
        { 
            StringBuilder sb = new StringBuilder(); 
            sb.Append("<script type='text/javascript'>\r\n"); 
            sb.Append("function rowDropping(sender, eventArgs)\r\n{\r\n"); 
            sb.Append("var htmlElement = eventArgs.get_destinationHtmlElement();\r\n"); 
            sb.Append("var scheduler = $find('" + myScheduler.ClientID + "');\r\n"); 
            sb.Append("if (isPartOfSchedulerAppointmentArea(htmlElement))\r\n{\r\n"); 
            sb.Append("var timeSlot = scheduler._activeModel.getTimeSlotFromDomElement(htmlElement);\r\n"); 
            sb.Append("$get('" + hid.ClientID + "').value = timeSlot.get_index();\r\n"); 
            sb.Append("eventArgs.set_destinationHtmlElement('" + hid.ClientID + "');\r\n}\r\nelse\r\n{\r\n"); 
            sb.Append("eventArgs.set_cancel(true);\r\n}\r\n}\r\n"); 
            sb.Append("function isPartOfSchedulerAppointmentArea(htmlElement)\r\n{\r\n"); 
            sb.Append("return    $telerik.$(htmlElement).parents().is('div.rsAllDay') || \r\n"); 
            sb.Append("$telerik.$(htmlElement).parents().is('div.rsContent')\r\n}\r\n"); 
            sb.Append("function onRowDoubleClick(sender, args)\r\n{\r\n"); 
            sb.Append("sender.get_masterTableView().editItem(args.get_itemIndexHierarchical());\r\n}\r\n"); 
            sb.Append("</script>"); 
            return sb.ToString(); 
        } 

Notice I had to do the same thing with the hidden field (hid).
0
utchi
Top achievements
Rank 1
answered on 04 Dec 2009, 06:33 AM

Hi,

 

Thanks you so much, its working.

 

Have a sweet, nice, happy, smiley, joyful, colorful day always.

With Smile,
Utchimahali ;)

Asked by
utchi
Top achievements
Rank 1
Answers by
Peter
Telerik team
utchi
Top achievements
Rank 1
Joe
Top achievements
Rank 1
Share this question
or