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

Expand PanelBar Item on page validation

1 Answer 74 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Thomas Mittag
Top achievements
Rank 1
Thomas Mittag asked on 14 Oct 2010, 02:38 PM
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?

1 Answer, 1 is accepted

Sort by
0
Kalina
Telerik team
answered on 22 Oct 2010, 12:57 PM
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
Tags
PanelBar
Asked by
Thomas Mittag
Top achievements
Rank 1
Answers by
Kalina
Telerik team
Share this question
or