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

Getting reference to RadPanelBar in IE

4 Answers 66 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Amir
Top achievements
Rank 1
Amir asked on 18 Sep 2010, 02:18 PM
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?

4 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 22 Sep 2010, 03:53 PM
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.
0
Nikolay Tsenkov
Telerik team
answered on 27 Sep 2010, 04:12 PM
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
0
Neerajan
Top achievements
Rank 1
answered on 26 Dec 2011, 06:50 AM
 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
0
Kate
Telerik team
answered on 28 Dec 2011, 03:57 PM
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
Tags
PanelBar
Asked by
Amir
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Nikolay Tsenkov
Telerik team
Neerajan
Top achievements
Rank 1
Kate
Telerik team
Share this question
or