Expand PanelBar Item on page validation

2 posts, 0 answers
  1. Thomas Mittag
    Thomas Mittag avatar
    19 posts
    Member since:
    Jun 2008

    Posted 14 Oct 2010 Link to this post

    I have a scenario where a page contains many panel bar items. Each item contains fields that may be required. Currently on the overall save of the page, the required field validators fire. But if a validator is hidden in a collapsed panel bar item, the user does not see why the save is not working. 

    I would like to avoid using a validator summary. Is there a way to create a script that would expand the parent item on the client side if a validator inside the item template fires?
  2. Kalina
    Admin
    Kalina avatar
    918 posts

    Posted 22 Oct 2010 Link to this post

    Hi Thomas Mittag,

    I am afraid that the behaviour that you describe is not officially supported.
    However I can suggest you expand all RadPanelBar items when Page is not valid:

    <script type="text/javascript">
     
        function OnClientClickHandler() {
     
            var panelBar = $find("<%=RadPanelBar1.ClientID %>");
            if (Page_ClientValidate() == false) {
                for (i = 0; i < Page_Validators.length; i++) {
     
                    if (!Page_Validators[i].isvalid) {
     
                        var items = panelBar.get_allItems();
                        for (var i = 0; i < panelBar.get_allItems().length; i++) {
                              panelBar.get_allItems()[i].expand();
                        }
     
                    }
                }
            }
        }
     
    </script>
     
    <asp:Button ID="btn" runat="server" Text="Submit"
        OnClientClick="OnClientClickHandler()" />
    <telerik:RadPanelBar ID="RadPanelBar1" runat="server"
        ExpandMode="MultipleExpandedItems">
        <Items>
            <telerik:RadPanelItem Text="RadPanelItem 1"
                runat="server" Expanded="True">
                <Items>
                    <telerik:RadPanelItem
                        Text="RadPanelItem 1-1" runat="server">
                        <ContentTemplate>
                            <asp:TextBox ID="TextBox1" runat="server">
                                </asp:TextBox>
                            <asp:RequiredFieldValidator
                                ID="RequiredFieldValidator1"
                                runat="server" ErrorMessage="*"
                                ControlToValidate="TextBox1">
                                </asp:RequiredFieldValidator>
                        </ContentTemplate>
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem
                        Text="RadPanelItem 1-2" runat="server">
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
            <telerik:RadPanelItem Text="RadPanelItem 2" runat="server">
                <Items>
                    <telerik:RadPanelItem
                        Text="RadPanelItem 2-1" runat="server">
                    </telerik:RadPanelItem>
                    <telerik:RadPanelItem
                        Text="RadPanelItem 2-2" runat="server">
                        <ContentTemplate>
                            <asp:TextBox ID="TextBox2" runat="server">
                                </asp:TextBox>
                            <asp:RequiredFieldValidator
                                ID="RequiredFieldValidator2"
                                runat="server" ErrorMessage="*"
                                ControlToValidate="TextBox2">
                                </asp:RequiredFieldValidator></ContentTemplate>
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>

    Best wishes,
    Kalina
    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
Back to Top