PanelBar - postback on expansion only

3 posts, 1 answers
  1. Sphengle
    Sphengle avatar
    29 posts
    Member since:
    Sep 2007

    Posted 11 May 2010 Link to this post

    I have a panel bar which is divided into sections.  Within each subsection there are RadPanelItems that are links to other pages.  One of the things I do is to put a number such as (59) next to the item text to indicate how many items will be listed when the user clicks on the link. 

    With the aid of RadAjaxManager I am updating the links via an Ajax call when the section is expanded. i.e.I am hooking into the ItemOnclick event and updating the links in the expanded section.  However, an Ajax postback occurs when I contract the section as well - it is this postback that I want to avoid. 

    Any suggestions on how to do this?

    Thanks.
  2. Answer
    Yana
    Admin
    Yana avatar
    4554 posts

    Posted 14 May 2010 Link to this post

    Hi Sphengle,

    I suggest you subscribe to OnClientItemClicking event of the panelbar and disable the postback in its handler in case the item is about to collapse. Here is a sample code snippet:

    <script type="text/javascript">
        function itemClicking(sender, args) {
            var item = args.get_item();
            if (item.get_level() == 0) {
                if (item.get_expanded() == true)
                    item.set_postBack(false);
                else
                    item.set_postBack(true);
            }
        }
    </script>


    All the best,
    Yana
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sphengle
    Sphengle avatar
    29 posts
    Member since:
    Sep 2007

    Posted 14 May 2010 Link to this post

    Excellent!  That's perfect.  Thank you very much.
Back to Top