I recently upgraded my controls to the 2014 Q2 Release and discovered that a page on my site was not working the way it had with the previous release of the controls that I had been using (2012 Q3... I know, it has been a while since we upgraded).
The page has a RadTabStrip with multiple tabs/pages. One of the RadPageView nodes contains an panel with a RadGrid which contains a NestedViewTemplate with a Save and Cancel button on it.
The functionality I want is that the user should not be able to switch to a different tab while the NestedViewTemplate contents are visible (this functionality didn't work in the previous version; however, the validation blocked the switch as long as data was not keyed into the textbox). If the Save button is clicked, the data would be validated and if valid the NestedViewTemplate contents are no longer shown (this functionality works). If the Cancel button is clicked, the NestedViewTemplate contents are no longer shown (works but...) and if the user then attempts to switch to a different tab, they should be able to (this is what does not work in the new release, but did work in the old release).
What do I need to do to insure the user cannot tab when the NestedViewTemplate is open and so they can tab when it is closed via the "Cancel" button?
Here is the CodeBehind:
Here is the Markup for the page:
The page has a RadTabStrip with multiple tabs/pages. One of the RadPageView nodes contains an panel with a RadGrid which contains a NestedViewTemplate with a Save and Cancel button on it.
The functionality I want is that the user should not be able to switch to a different tab while the NestedViewTemplate contents are visible (this functionality didn't work in the previous version; however, the validation blocked the switch as long as data was not keyed into the textbox). If the Save button is clicked, the data would be validated and if valid the NestedViewTemplate contents are no longer shown (this functionality works). If the Cancel button is clicked, the NestedViewTemplate contents are no longer shown (works but...) and if the user then attempts to switch to a different tab, they should be able to (this is what does not work in the new release, but did work in the old release).
What do I need to do to insure the user cannot tab when the NestedViewTemplate is open and so they can tab when it is closed via the "Cancel" button?
Here is the CodeBehind:
Imports System.DataImports Telerik.Web.UIPublic Class TestPage Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Dim dt As New DataTable("MyData") Dim i As Integer = 1 dt.Columns.Add("Key", GetType(Integer)) dt.Columns.Add("Description", GetType(String)) Dim dr As DataRow = dt.NewRow dr("Key") = 1 dr("Description") = "My Data Row" dt.Rows.Add(dr) Me.MyList.DataSource = dt Me.MyList.DataBind() End If End Sub Public Sub MyList_ItemCommand(ByVal sender As Object, ByVal e As GridCommandEventArgs) If (e.CommandName = RadGrid.ExpandCollapseCommandName) Then If Not e.Item.Expanded Then AdjustPageAvailability(False) End If End If End Sub Public Sub MyList_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) If (TypeOf e.Item Is GridDataItem) Then Dim item = CType(e.Item, GridDataItem) Dim column = item("ExpandColumn") If (column IsNot Nothing) Then column.Controls(0).Visible = True End If End If End Sub Protected Sub Cancel_Click(ByVal sender As Object, ByVal e As EventArgs) For Each item As GridDataItem In MyList.Items If item.Expanded Then item.Expanded = False End If Next Me.AdjustPageAvailability(True) End Sub Protected Sub Save_Click(ByVal sender As Object, ByVal e As EventArgs) Page.Validate(CType(sender, IButtonControl).ValidationGroup) If (Not Page.IsValid) Then Return End If For Each item As GridDataItem In MyList.Items If item.Expanded Then item.Expanded = False End If Next Me.AdjustPageAvailability(True) End Sub Private Sub AdjustPageAvailability(ByVal visible As Boolean) Dim column As TableCell For Each item As GridDataItem In Me.MyList.Items column = item("ExpandColumn") If (column IsNot Nothing) Then column.Controls(0).Visible = visible End If Next End SubEnd ClassHere is the Markup for the page:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestPage.aspx.vb" Inherits="Telerik2014Q2Issue.TestPage" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title></head><body> <form id="form1" runat="server"> <div> <tel:RadScriptManager ID="sm" runat="server" ClientIDMode="Static" > </tel:RadScriptManager> <tel:RadTabStrip ID="DetailsTabs" runat="server" SelectedIndex="0" MultiPageID="DetailsPages"> <Tabs> <tel:RadTab runat="server" Text="Details" /> <tel:RadTab runat="server" Text="History" /> </Tabs> </tel:RadTabStrip> <tel:RadMultiPage ID="DetailsPages" runat="server" SelectedIndex="0"> <tel:RadPageView ID="RadPageView1" runat="server"> <asp:Panel runat="server" ID="DetailsForm"> <h3>DEP Well Details</h3> <p> <tel:RadGrid ID="MyList" runat="server" OnItemDataBound="MyList_ItemDataBound" OnItemCommand="MyList_ItemCommand"> <MasterTableView AutoGenerateColumns="False" AllowPaging="False" AllowSorting="False" AllowCustomPaging="False" HierarchyLoadMode="ServerOnDemand" DataKeyNames="Key"> <Columns> <tel:GridBoundColumn HeaderText="Description" DataField="Description" /> </Columns> <NestedViewTemplate> <asp:Panel ID="Panel1" runat="server"> <h3>More Details</h3> <div> <asp:ValidationSummary ID="MyValidationSummary" runat="server" HeaderText="The following errors have occurred:" /> <table> <thead></thead> <tbody> <tr> <td> <tel:RadTextBox ID="txtNotes" runat="server" TextMode="MultiLine" Rows="4" Columns="60" CssClass="MultiLineTextBox" /> </td> </tr> <tr> <td> <asp:RequiredFieldValidator ID="NotesRequired" runat="server" ControlToValidate="txtNotes" Text="* Required" ErrorMessage="Please enter a something in the box." /> </td> </tr> </tbody> </table> </div> <div> <ul class="inline"> <li> <tel:RadButton ID="Save" runat="server" Text="Save" CausesValidation="true" OnClick="Save_Click" /> </li> <li> <tel:RadButton ID="Cancel" runat="server" Text="Cancel" CausesValidation="false" OnClick="Cancel_Click" /> </li> </ul> </div> </asp:Panel> </NestedViewTemplate> </MasterTableView> </tel:RadGrid> </p> </asp:Panel> </tel:RadPageView> <tel:RadPageView ID="RadPageView2" runat="server"> <div> <p>History</p> </div> </tel:RadPageView> </tel:RadMultiPage> </div> </form></body></html>