Edit this page

Load All Items on Initial Page Load

Q: How can I prevent a delay in the page load when I have a RadMenu with a large number of items?

A: In general the delay is caused by the so called ‘lazy initialization’ mechanism - Item objects are initializedin the latest possible moment in the control life cycle. This is the first time Items are accessedwith the get_allItems() method, which happens automatically right before the item opens.

You could avoid this delay, or more specifically 'move' it to the initial page load, by calling get_items early in the page life cycle either for all RadMenus on the page or for individual ones.

The first approach uses the pageLoad function as shown below:

function pageLoad(){ 
    var menu = $find("<%= RadMenu1.ClientID %>");
    //initialize all items
    var items = menu.get_allItems();
}   

The second approach uses the OnClientLoad event of a single RadMenu:

<telerik:RadMenu RenderMode="Lightweight" ID="RadMenu1" runat="server" OnClientLoad="(function(sender, e){ sender.get_allItems(); })" />