This is a migrated thread and some comments may be shown as answers.

Scheduler/Grid drag and drop issue

1 Answer 43 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Karl
Top achievements
Rank 1
Karl asked on 27 Jan 2012, 11:14 AM
Hi
I am using a RadGrid to drag and drop onto a RadScheduler. The page works and functions exactly as required in a standard page, however, when I place exactly the same code into a page that calls a masterpage I get a javascript error "'null' is null or not an object"

I'm assuming this would be something to do with the following javascript, however I cant pinpoint exactly what.

<script type="text/javascript">
            function rowDropping(sender, eventArgs) {
                // Fired when the user drops a grid row
                var htmlElement = eventArgs.get_destinationHtmlElement();
                var scheduler = $find('<%= RadScheduler1.ClientID %>');
  
                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);
                    alert(timeSlot.get_index());
                    $get("TargetSlotHiddenField").value = timeSlot.get_index();
  
                    // The HTML needs to be set in order for the postback to execute normally
                    eventArgs.set_destinationHtmlElement("TargetSlotHiddenField");
                }
                else {
                    // The node was dropped elsewhere on the document
                    eventArgs.set_cancel(true);
                }
            }
  
            function isPartOfSchedulerAppointmentArea(htmlElement) {
                return $telerik.$(htmlElement).parents().is("div.rsAllDay") ||
                            $telerik.$(htmlElement).parents().is("div.rsContent")
            }
  
            function onRowDoubleClick(sender, args) {
                sender.get_masterTableView().editItem(args.get_itemIndexHierarchical());
            }
        </script>


Any pointers on why this wouldnt work on a page that calls a masterpage would be much appreciated - I tested this with a masterpage that was essentially blank as well with no other scripts included on it.

Many thanks.
Karl.

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 31 Jan 2012, 01:24 PM
Hello Karl,

 
Thank you for contacting Telerik support.

It seems that the id of the hidden field is dynamically changed when it is put in a ContentPlaceHolder. You can use jQuery as in the following code to get it:

var TargetSlotHiddenFieldObject = $telerik.$("[id$='TargetSlotHiddenField']");
                  $get(TargetSlotHiddenFieldObject.attr('id')).value = timeSlot.get_index();

Here I am attaching a sample demo as well.

Hope this will be helpful.

Regards,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Scheduler
Asked by
Karl
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or