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

RadGrid Paging Error in _destroyTree

6 Answers 327 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 25 Apr 2012, 02:50 PM

I'm using an older version of Telerik that doesn't have the ASP 4.0 fix and it's causing my grid control to throw an error when paging.  The error is:  Microsoft JScript runtime error: Object doesn't support property or method '_destroyTree'

I found a fix on these forums that works very well when used on a normal ASPX page... 

<script type="text/javascript">
$telerik.disposeElement = function (element) {
if (typeof (Sys.WebForms) == "undefined")
return;
var prm = Sys.WebForms.PageRequestManager.getInstance();
if (prm && prm._destroyTree)
prm._destroyTree(element);
else if (Sys.Application.disposeElement)
Sys.Application.disposeElement(element, true);
};
Telerik.Web.UI.RadComboBox.prototype._removeDropDown = function () {
var slide = this.get_dropDownElement().parentNode;
slide.parentNode.removeChild(slide);
if (this._disposeChildElements)
$telerik.disposeElement(slide);
if (!$telerik.isSafari)
slide.outerHTML = null;
this._dropDownElement = null;
};
</script>


My problems is that I am using user controls on much of the site.  If I place this in the ASCX file, I get the same error as if I didn't have it there.  If I place it in the ASPX that the user control is added to, I get this error: Microsoft JScript runtime error: Unable to get value of the property 'prototype': object is null or undefined most likely because the user control with the grid isn't loaded yet.

I can place the script inside an IF statement... if (Telerik.Web.UI.RadComboBox != null) { } and that gets rid of the prototype error, but it acts like the script isn't there because I still get the original _destroyTree error.

Can someone tell me what I need to do in order to make this work inside a user control?  Here's the layout of my pages...

  • Master Page with update panel and placeholders.
    • Inside one placeholder, I have a sidebar where I have an accordion menu.
      • This placeholder is filled in with an ASPX page.
    • Inside the other placeholder, I have the main content area.
      • This placeholder is filled in with an ASCX user control based on what is clicked on the menu in the first placeholder.
      • Separate user controls are loaded dynamically based on the menu selection.
      • The user controls in this placeholder are where my grids are that need paging.

So what I need is to include the fix script in each user control that uses a grid so that I can page.  If it were possible to include it on the master page so I don't have to put it on every user control, or if I could put it on the ASPX page that is in the first placeholder and have it work even when a new user control is loaded, then that would be great.  But I don't mind including it in every user control if that is what's needed for this to work.  I can also include a .JS file if that is what's needed.  Keep in mind that these are inside an update panel, so the postback will be asynchronous in case that matters.

Any help would be greatly appreciated.  It was decided that we wouldn't be updating Telerik, so I'm stuck with trying to make this work with just the script fix.  This is really the only issue I'm having with Telerik and 4.0 with our site, so there isn't enough incentive to buy a newer version.

Just as a reminder, the script above works perfectly when used on a normal ASPX page that has the grid right on it rather than the grid being on a user control that is loaded later.

6 Answers, 1 is accepted

Sort by
0
Jeremy
Top achievements
Rank 1
answered on 25 Apr 2012, 07:10 PM

Here's an update on where I am right now...

I was able to include the patch script shown above as a .js file using:

 

 

ScriptManager.RegisterClientScriptInclude(this, GetType(), "TelerikFix", ResolveUrl("~/Scripts/TelerikFix.js"));

 


I was able to test that this is loading correctly by using a breakpoint in that file.  Unfortunately, I am left with the same _destroyTree error message.  Also, the first user control that is loaded with this in it shows the following 2 error messages:
Microsoft JScript runtime error: '$telerik' is undefined
and
Microsoft JScript runtime error: 'Telerik' is undefined (this appears twice)

That only happens in the first user control that is loaded.  Other user controls don't give that error message, but do still fail to page properly.  And if I go back to that user control, it doesn't give that error.

I'm not sure if this helps to figure out what I need to do, but I wanted to at least give as much information as possible.

Also note that the _destroyTree error occurs not just when changing pages, but also with closing/refreshing the grid in any way (closing the user control, sorting by columns, expanding/minimizing groups, etc) whenever paging is enabled.  And, again, the fix above works fine on an ASPX page that holds all of the controls on it, but is not working when the grids are in user controls.
0
Vasil
Telerik team
answered on 30 Apr 2012, 11:32 AM
Hello Jeremy,

Make sure the script resources are loaded properly in the browser when you load the page. Check this help topics:
http://www.telerik.com/help/aspnet-ajax/introduction-troubleshooting.html
http://www.telerik.com/help/aspnet-ajax/introduction-web-resources-troubleshooting.html

If you have some complex scenario and not sure if all scripts are loaded correctly (if you add some controls too late in the page life cycle). You could try to include them manually:
http://www.telerik.com/help/aspnet-ajax/introduction-disabling-embedded-resources.html

Regards,
Vasil
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.
0
Jeremy
Top achievements
Rank 1
answered on 30 Apr 2012, 12:18 PM
Thank you for your response.  The links you posted regarding those Telerik undefined error messages aren't really the root of the problem.  I understand why those errors occur... I'm trying to run a javascript on something that isn't on the page.  I was including that as additional reference to show what I've tried to do on my own, but my main issue is with the _destroyTree error message.  I need to know how to use that patch script within a user control.  Any help with that would be greatly appreciated.
0
Vasil
Telerik team
answered on 30 Apr 2012, 12:57 PM
Hi Jeremy,

If you register the scripts manually you will know when exactly are loaded and do the function override in the proper time.
What you could try now is to run the site and when you get the error examine the JavaScript CallStack. Go up into the stack to see if it passes thought some function that you could override directly into the master page, function that you know it is loaded earlier before the Ajax, and add your code to it.
You can see from the callstack which control is causing the error when it get's disposed, and to register the script just after the declaration of the very same control.

All the best,
Vasil
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.
0
Jeremy
Top achievements
Rank 1
answered on 02 May 2012, 06:25 PM
Sorry for the delay in replying.  I've been busy with a major upgrade here.  I will attempt that and see what I can find out.
0
Jeremy
Top achievements
Rank 1
answered on 07 May 2012, 07:57 PM
Well, I've spent a lot of time trying to figure out how to get that patch to work and haven't had any luck.  I'm still new to developing for .NET and have minimal javascript experience, so trying to find this stuff is not a simple matter.  Thankfully, I have finally been able to get approval to update our copy of Telerik, so we'll be able to get the fix built in instead of manually fixing it with the patch.  I appreciate the help.  If anyone wants to contribute with how exactly to use the patch in a usercontrol situation where the usercontrol is in an update panel so that others can make use of it, that would be great.  But I am all set thanks to getting the approval to update our copy of Telerik.  Now that we're moving everything we have to .NET 4.0, it will be very helpful.  Thanks again and have a great day.

Further details just in case anyone needs/wants them--
The _destroyTree error occurs when you do anything that requires changing displayed data in the grid.  As soon as you click to change a page on a multipage grid, or sort a multipage grid, or close the usercontrol that has the multipage grid, the _destroyTree error occurs.  Below is the function where that error is located.

_removeDropDown:function(){
var _31=this.get_dropDownElement().parentNode;
_31.parentNode.removeChild(_31);
if(this._disposeChildElements){
Sys.WebForms.PageRequestManager.getInstance()._destroyTree(_31);
}
Tags
Grid
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Jeremy
Top achievements
Rank 1
Vasil
Telerik team
Share this question
or