Getting reference to RadPanelBar in IE

5 posts, 0 answers
  1. Amir
    Amir avatar
    15 posts
    Member since:
    Sep 2006

    Posted 18 Sep 2010 Link to this post

    Hi,
    I have a radpanelbar with PersistStateInCookie="True". It's is populated dynamically in code behind. I want to write a javascript code to check if there is no level 0 item expanded then it expands the last level 0 item. I have written the following code:
    function ExpandFirst() {
        var panelBar = $find("<%= _radpnlbarMenu.ClientID %>");
        if (panelBar) {
            var item = panelBar.get_expandedItem();
            if (panelBar.get_expandedItem() == null) {
                var items = panelBar.get_items();
                if (items.get_count() > 0)
                    items.getItem(items.get_count() - 1).expand();
            }
        }
    }
     
    $(document).ready(function() {
        ExpandFirst();
    });



    <telerik:RadPanelBar OnItemDataBound="RadpnlbarMenuOnItemDataBound" runat="server" ID="_radpnlbarMenu" ExpandAnimation-Type="InQuart" ExpandAnimation-Duration="500" CollapseAnimation-Duration="500" CollapseAnimation-Type="InQuart" Height="250px" ExpandMode="FullExpandedItem" PersistStateInCookie="True">
        <DataBindings>
            <telerik:RadPanelItemBinding Depth="0" Expanded="true" />
        </DataBindings>
    </telerik:RadPanelBar>

    It works fine in Firefox but in IE the panelBar object is always null.
    Is this the best way to do the trick?
    Can you please help me?
  2. Cori
    Cori avatar
    562 posts
    Member since:
    Jul 2010

    Posted 22 Sep 2010 Link to this post

    Hello Amir,

    I would suggest calling the ExpandFirst method in the RadPanelBar's OnClientLoaded event, instead on ready. The reason for that is the ready event is called when the DOM is fully loaded, but since RadPanelBar's jQuery object isn't fully created before that event is raised it will return a null reference.

    Another option would be to add it like this:

    Sys.Application.add_load(ExpandFirst);

    Both approaches ensure that the RadPanelBar object has been created before trying to get a reference to it.

    I hope that helps.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 27 Sep 2010 Link to this post

    Hi Cori,

    Could you, please, try executing ExpandFirst on the ClientLoad event?
    Here is a help article for this client event of RadPanelBar: http://www.telerik.com/help/aspnet-ajax/panel_panelbar_onclientload.html

    Hope this is going to help you!


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Neerajan
    Neerajan avatar
    10 posts
    Member since:
    Dec 2011

    Posted 26 Dec 2011 Link to this post

     Hello,

    I also have the same issue but in my case i have to use RadPane  this doesnt have OnClientLoaded  function.
    Also, I need to call a method from another js file from this function. I tried using 

    function Expand(){
    var pane="<%= RadPane.ClientID%>"
    if(pane.IsLocked()){
    var splitter=pane.get_splitter();
            abc.ShowPane(splitter); // it is a method in another js file.
    }
    }
    Sys.Application.add_load(Expand());

    The isLocked() and get_splitter() are not accessible from the method Expand().
    How can i resolve the same issue?

    Thanks,
    Neerajan
  6. Kate
    Admin
    Kate avatar
    1898 posts

    Posted 28 Dec 2011 Link to this post

    Hi Neerajan,

    Please refer to Cori's post and use  Sys.Application.add_load(Expand); instead of Sys.Application.add_load(Expand());

    Further to be able to understand your scenario and help you out accessing the isLocked() and get_splitter() properties I would like to ask you to elaborate a bit on your case. For instance a simplified runnable page or just the markup demonstrating how you use the RadSplitter control would be very useful to us.

    Kind regards,
    Kate
    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017