Enable / Disable TabStrip Dynamically

4 posts, 0 answers
  1. Siva
    Siva avatar
    5 posts
    Member since:
    Oct 2014

    Posted 29 Jan 2015 Link to this post

    Is it possible to Enable or disable the Tab strip based on the Rad Grid Condition. I have Three Tabs and each tab has a RadGrid in it. When a Grid is in Edit mode, I want to Disbale the TasbStrip so that users can not move to a different Tab. Once the users either update or cancel the edit Tab Strip should be enabled back.

    I tried setting Tabstrip.enabled to false on Grid Prerender and Item Command, but did not work.

    Thanks for your help and advice.

    Thanks,
    Siva
  2. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 03 Feb 2015 Link to this post

    Hello,

    Thank you for contacting Telerik support.

    Please, see the following code snippet showing how to disable a RadTabStrip's tab in the RadGrid's PreRender event handler:

    protected void RadGrid1_PreRender(object sender, System.EventArgs e)
    {
        if (!IsPostBack)
        {
            RadGrid1.MasterTableView.Items[3].Edit = true;
            RadGrid1.Rebind();
     
            if (RadGrid1.MasterTableView.Items[3].Edit == true)
            {
                var tab = RadTabStrip1.FindTabByText("Documentation");
                tab.Enabled = false;
            }
        }
    }
     
    protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        List<MyClass> list = new List<MyClass>();
     
        list.Add(new MyClass { Age = 12, Text = "John" });
        list.Add(new MyClass { Age = 32, Text = "Peter" });
        list.Add(new MyClass { Age = 22, Text = "Monica" });
        list.Add(new MyClass { Age = 51, Text = "Kalvin" });
        list.Add(new MyClass { Age = 44, Text = "Terry" });
     
        RadGrid1.DataSource = list;
    }
     
    public class MyClass
    {
        public int Age { get; set; }
        public string Text { get; set; }
    }

          1. In the code-behind we first populate a RadGrid with sample data using its NeedDataSource event handler.

         2. Then we put its third item into Edit mode in the PreRender event handler. If you want to disable a tab if a particular grid item is in edit mode you can make that check here. In our example we check if the third item is in edit mode and then we disable a tab with a specific text value.

    I hope this was useful. Feel free to contact us again if you have more questions.

    Regards,
    Ivan Danchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Siva
    Siva avatar
    5 posts
    Member since:
    Oct 2014

    Posted 03 Feb 2015 in reply to Ivan Danchev Link to this post

    Unfortunately the above code is not working in my case.
    I am attaching the code snippet I have. Could you pleae check what is going wrong here
    in ASPX i have the following code

     

    <telerik:RadMultiPage id="ReferencesRadMultiPage" runat="server" SelectedIndex="0"  >
                <telerik:RadPageView id="OfcRadPageView" runat="server">
                    <telerik:RadAjaxPanel ID="OfcRadAjaxPanel" runat="server">
                        <div>     
                            <asp:Label ID="OfcErrmsg" runat="server" Text="" EnableViewState="false" ForeColor="Red"></asp:Label>
                            <telerik:RadGrid ID="OfficeRadGrid" runat="server" Width="550px"
                                AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                                DataSourceID="OfficeSqlDataSource" GroupPanelPosition="Top"
                                CellSpacing="-1" GridLines="Both"
                                AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                                AllowAutomaticDeletes="True" OnPreRender="OfficeRadDataForm_PreRender" OnItemCommand="OfficeRadGrid_ItemCommand" OnItemDeleted="OfficeRadGrid_ItemDeleted">
                                <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
                                <MasterTableView DataKeyNames="Officeuid" EditMode="InPlace" CommandItemDisplay="Bottom" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                                    <EditFormSettings>
                                        <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                                            UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" ItemStyle-Width="20px" Reorderable="True" FooterStyle-Width="20px" HeaderStyle-Width="20px">
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn DataField="Officeuid" DataType="System.Int32" FilterControlAltText="Filter Office uid column" HeaderText="Office uid"
                                            UniqueName="Officeuid" Visible="false" ReadOnly="True">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Office" HeaderText="Office"  SortExpression="Office" UniqueName="Office" FilterControlAltText="Filter Office column">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="OfficeDescription" HeaderText="Office Description"  SortExpression="OfficeDescription" UniqueName="OfficeDescription" FilterControlAltText="Filter Office Description column">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="OfficeKey" HeaderText="Office Key"  SortExpression="Office Key" UniqueName="OfficeKey" FilterControlAltText="Filter Office Key column" MaxLength="1">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridCheckBoxColumn DataField="Active" HeaderText="Active" SortExpression="Active" UniqueName="Active" FilterControlAltText="Filter Active column" ReadOnly="False" Visible="True" DataType="System.Boolean" >
                                        </telerik:GridCheckBoxColumn>
                                        <telerik:GridButtonColumn ConfirmText="Delete this Office?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                            <HeaderStyle Width="50px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                    <HeaderStyle Height="50px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    <ItemStyle VerticalAlign="Top" />
                                    <EditItemStyle VerticalAlign="Top" />
                                </MasterTableView>
                                <ClientSettings>
     
                 
     
            </ClientSettings>
                            </telerik:RadGrid>
                            <asp:SqlDataSource ID="OfficeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CPMConnectionString %>"
                SelectCommand="[procOfficeRef_Select]" SelectCommandType="StoredProcedure"
                UpdateCommand="[procOfficeRef_Update]" UpdateCommandType="StoredProcedure"
                InsertCommand="[procOfficeRef_Insert]" InsertCommandType="StoredProcedure"
                DeleteCommand="[procOfficeRef_Delete]" DeleteCommandType="StoredProcedure"
                >
                </asp:SqlDataSource>           
                        </div>
                    </telerik:RadAjaxPanel>
                </telerik:RadPageView>
     
                <telerik:RadPageView id="TasksRadPageView" runat="server">
                    <telerik:RadAjaxPanel ID="TasksRadAjaxPanel" runat="server">
                        <div>     
                            <asp:Label ID="TskErrmsg" runat="server" Text="" EnableViewState="false" ForeColor="Red"></asp:Label>
                            <telerik:RadGrid ID="TasksRadGrid" runat="server" Width="550px"
                                AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                                DataSourceID="TaskSqlDataSource" GroupPanelPosition="Top"
                                CellSpacing="-1" GridLines="Both"
                                AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                                AllowAutomaticDeletes="True" OnPreRender="TaskRadDataForm_PreRender" OnItemCommand="TasksRadGrid_ItemCommand" OnItemDeleted="TaskRadGrid_ItemDeleted">
                                <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
                                <MasterTableView DataKeyNames="TaskUId" EditMode="InPlace" CommandItemDisplay="Bottom" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                                    <EditFormSettings>
                                        <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                                            UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" ItemStyle-Width="20px" Reorderable="True" FooterStyle-Width="20px" HeaderStyle-Width="20px">
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn DataField="TaskUId" DataType="System.Int32" FilterControlAltText="Filter Task id column" HeaderText="Task UID"
                                            SortExpression="TaskUId" UniqueName="TaskUId" Visible="false" ReadOnly="True">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="TaskID" HeaderText="Task"  SortExpression="TaskID" UniqueName="TaskID" FilterControlAltText="Filter Task column">
                                        </telerik:GridBoundColumn>
     
                                        <telerik:GridBoundColumn DataField="TaskTitle" HeaderText="Task Title"  SortExpression="TaskTitle" UniqueName="TaskTitle" FilterControlAltText="Filter Task Title column">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridDropDownColumn DataField="OfficeUID" UniqueName="OfficeUID" SortExpression="OfficeUID" HeaderText="Office"
                                            DataSourceID="OfficeSqlDataSource" ListTextField="Office" ListValueField="OfficeUID"
                                            ></telerik:GridDropDownColumn>
                                        <telerik:GridDropDownColumn DataField="EmployerID" UniqueName="Employer" SortExpression="EmployerID" HeaderText="Employer"
                                            DataSourceID="EmployersSqlDataSource" ListTextField="Employer" ListValueField="EmployerID"
                                            >
                                        </telerik:GridDropDownColumn>
     
                                       <telerik:GridCheckBoxColumn DataField="Active" DataType="System.Boolean"
                                            FilterControlAltText="Filter Active column" HeaderText="Active" ReadOnly="False"
                                            SortExpression="Active" UniqueName="Active" Visible="True">
                                        </telerik:GridCheckBoxColumn>
                                        
                                        <telerik:GridButtonColumn ConfirmText="Delete this Task?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                            <HeaderStyle Width="50px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                    <HeaderStyle Height="50px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    <ItemStyle VerticalAlign="Top" />
                                    <EditItemStyle VerticalAlign="Top" />
                                </MasterTableView>
                                <ClientSettings>
            </ClientSettings>
                            </telerik:RadGrid>
                            <asp:SqlDataSource ID="TaskSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CPMConnectionString %>"
                SelectCommand="[procTaskRef_Select]" SelectCommandType="StoredProcedure"
                UpdateCommand="[procTaskRef_Update]" UpdateCommandType="StoredProcedure"
                InsertCommand="[procTaskRef_Insert]" InsertCommandType="StoredProcedure"
                DeleteCommand="[procTaskRef_Delete]" DeleteCommandType="StoredProcedure"
                >
                </asp:SqlDataSource>
                        </div>
                    </telerik:RadAjaxPanel>
                </telerik:RadPageView>
     
                <telerik:RadPageView id="EmployersRadPageView" runat="server">
                    <telerik:RadAjaxPanel ID="EmployersRadAjaxPanel" runat="server">
                    <div>
                        <asp:Label ID="EmpErrmsg" runat="server" Text="" EnableViewState="false" ForeColor="Red"></asp:Label>
                        <telerik:RadGrid ID="EmployerRadGrid" runat="server" Width="550px"
                                AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                                DataSourceID="EmployersSqlDataSource" GroupPanelPosition="Top"
                                CellSpacing="-1" GridLines="Both"
                                AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                                AllowAutomaticDeletes="True" OnPreRender="EmployerRadDataForm_PreRender" OnItemCommand="EmployerRadGrid_ItemCommand" OnItemDeleted="EmployerRadGrid_ItemDeleted">
                                <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
                                <MasterTableView DataKeyNames="Employerid" EditMode="InPlace" CommandItemDisplay="Bottom" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                                    <EditFormSettings>
                                        <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                                            UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" ItemStyle-Width="20px" Reorderable="True" FooterStyle-Width="20px" HeaderStyle-Width="20px">
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn DataField="Employerid" DataType="System.Int32" FilterControlAltText="Filter Employer id column" HeaderText="Employer Uid"
                                            SortExpression="Employerid" UniqueName="Employerid" Visible="false" ReadOnly="True">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="Employer" HeaderText="Employer"  SortExpression="Employer" UniqueName="Employer" FilterControlAltText="Filter Employer column">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridCheckBoxColumn DataField="Active" HeaderText="Active" SortExpression="Active" UniqueName="Active" FilterControlAltText="Filter Active column" ReadOnly="False" Visible="True" DataType="System.Boolean" >
                                        </telerik:GridCheckBoxColumn>
                                        <telerik:GridButtonColumn ConfirmText="Delete this Employer?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                            <HeaderStyle Width="50px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                    <HeaderStyle Height="50px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    <ItemStyle VerticalAlign="Top" />
                                    <EditItemStyle VerticalAlign="Top" />
                                </MasterTableView>
                                <ClientSettings>
     
                <%--<ClientEvents OnCommand="gridCommand"></ClientEvents>--%>
     
            </ClientSettings>
                            </telerik:RadGrid>
                        <asp:SqlDataSource ID="EmployersSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CPMConnectionString %>"
                SelectCommand="procEmployerRef_Select" SelectCommandType="StoredProcedure"
                InsertCommand="procEmployerRef_Insert" InsertCommandType="StoredProcedure"
                UpdateCommand="procEmployerRef_Update" UpdateCommandType="StoredProcedure"
                DeleteCommand="procEmployerRef_Delete" DeleteCommandType="StoredProcedure"
                >
                </asp:SqlDataSource>
                    </div>
                    </telerik:RadAjaxPanel>
                </telerik:RadPageView>
                <telerik:RadPageView id="PositionsRadPageView" runat="server">
                    <telerik:RadAjaxPanel ID="PositionsRadAjaxPanel" runat="server">
                        <div>
                            <asp:Label ID="PosErrmsg" runat="server" Text="" EnableViewState="false" ForeColor="Red"></asp:Label>
                            <telerik:RadGrid ID="PossitionsRadGrid" runat="server" Width="550px"
                                AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                                DataSourceID="PositionsRefSqlDataSource" GroupPanelPosition="Top"
                                CellSpacing="-1" GridLines="Both"
                                AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                                AllowAutomaticDeletes="True" OnPreRender="PositionRadDataForm_PreRender" OnItemCommand="PossitionsRadGrid_ItemCommand" OnItemDeleted="PositionRadGrid_ItemDeleted">
                                <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
                                <MasterTableView DataKeyNames="PositionUID" EditMode="InPlace" CommandItemDisplay="Bottom" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                                    <EditFormSettings>
                                        <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                                            UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" ItemStyle-Width="20px" Reorderable="True" FooterStyle-Width="20px" HeaderStyle-Width="20px">
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn DataField="PositionUID" DataType="System.Int32" FilterControlAltText="Filter Position uid column" HeaderText="Position uid"
                                            UniqueName="PositionUID" Visible="false" ReadOnly="True">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LCAT" HeaderText="LCAT"  SortExpression="LCAT" UniqueName="LCAT" FilterControlAltText="Filter LCAT column" MaxLength="10">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="PositionDescription" HeaderText="Position Description"  SortExpression="PositionDescription" UniqueName="PositionDescription" FilterControlAltText="Filter Position Description column" MaxLength="75">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridNumericColumn DataField="SortOrder" HeaderText="Sort Order"  SortExpression="SortOrder" UniqueName="SortOrder" FilterControlAltText="Filter Sort Order column" DataType="System.Int32" NumericType="Number" MaxLength="3">
                                        </telerik:GridNumericColumn>
                                        <telerik:GridCheckBoxColumn DataField="Active" HeaderText="Active" SortExpression="Active" UniqueName="Active" FilterControlAltText="Filter Active column" ReadOnly="False" Visible="True" DataType="System.Boolean" >
                                        </telerik:GridCheckBoxColumn>
                                        <telerik:GridButtonColumn ConfirmText="Delete this Position?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                            <HeaderStyle Width="50px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                    <HeaderStyle Height="50px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    <ItemStyle VerticalAlign="Top" />
                                    <EditItemStyle VerticalAlign="Top" />
                                </MasterTableView>
                                <ClientSettings>
            </ClientSettings>
                            </telerik:RadGrid>
                            <asp:SqlDataSource ID="PositionsRefSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CPMConnectionString %>"
                SelectCommand="[procPositionsRef_Select]" SelectCommandType="StoredProcedure"
                UpdateCommand="[procPositionsRef_Update]" UpdateCommandType="StoredProcedure"
                InsertCommand="[procPositionsRef_Insert]" InsertCommandType="StoredProcedure"
                DeleteCommand="[procPositionsRef_Delete]" DeleteCommandType="StoredProcedure"
                >
                </asp:SqlDataSource>
     
                        </div>
                    </telerik:RadAjaxPanel>
                </telerik:RadPageView>
             
                <telerik:RadPageView id="FormtypeRadPageView" runat="server">
                    <telerik:RadAjaxPanel ID="FormtypeRadAjaxPanel" runat="server">
                        <div>
                            <asp:Label ID="FormTypeErrmsg" runat="server" Text="" EnableViewState="false" ForeColor="Red"></asp:Label>
                            <telerik:RadGrid ID="FormTypeRadGrid" runat="server" Width="550px"
                                AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                                DataSourceID="FormTypeSqlDataSource" GroupPanelPosition="Top"
                                CellSpacing="-1" GridLines="Both"
                                AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                                AllowAutomaticDeletes="True" OnPreRender="FormTypeRadDataForm_PreRender" OnItemCommand="FormTypeRadGrid_ItemCommand" OnItemDeleted="FormTypeRadGrid_ItemDeleted">
                                <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
                                <MasterTableView DataKeyNames="FormTypeuid" EditMode="InPlace" CommandItemDisplay="Bottom" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                                    <EditFormSettings>
                                        <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                                            UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" ItemStyle-Width="20px" Reorderable="True" FooterStyle-Width="20px" HeaderStyle-Width="20px">
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn DataField="FormTypeuid" DataType="System.Int32" FilterControlAltText="Filter FormType uid column" HeaderText="FormType uid"
                                            UniqueName="FormTypeuid" Visible="false" ReadOnly="True">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="TableName" HeaderText="TableName"  SortExpression="TableName" UniqueName="TableName" FilterControlAltText="Filter TableName column">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="FormTypeDescription" HeaderText="FormType Description"  SortExpression="FormTypeDescription" UniqueName="FormTypeDescription" FilterControlAltText="Filter FormType Description column">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridNumericColumn DataField="SortOrder" HeaderText="Sort Order"  SortExpression="SortOrder" UniqueName="SortOrder" FilterControlAltText="Filter Sort Order column" DataType="System.Int32" NumericType="Number" MaxLength="3">
                                        </telerik:GridNumericColumn>
                                        <telerik:GridCheckBoxColumn DataField="Active" HeaderText="Active" SortExpression="Active" UniqueName="Active" FilterControlAltText="Filter Active column" ReadOnly="False" Visible="True" DataType="System.Boolean" >
                                        </telerik:GridCheckBoxColumn>
                                        <telerik:GridButtonColumn ConfirmText="Delete this FormType?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                            <HeaderStyle Width="50px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                    <HeaderStyle Height="50px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    <ItemStyle VerticalAlign="Top" />
                                    <EditItemStyle VerticalAlign="Top" />
                                </MasterTableView>
                                <ClientSettings>
                                </ClientSettings>
                            </telerik:RadGrid>
                            <asp:SqlDataSource ID="FormTypeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CPMConnectionString %>"
                SelectCommand="[procFormTypeRef_Select]" SelectCommandType="StoredProcedure"
                UpdateCommand="[procFormTypeRef_Update]" UpdateCommandType="StoredProcedure"
                InsertCommand="[procFormTypeRef_Insert]" InsertCommandType="StoredProcedure"
                DeleteCommand="[procFormTypeRef_Delete]" DeleteCommandType="StoredProcedure"
                >
                </asp:SqlDataSource>
                        </div>
                    </telerik:RadAjaxPanel>
                </telerik:RadPageView>
                
                <telerik:RadPageView id="AccessTypeRadPageView" runat="server">
                    <telerik:RadAjaxPanel ID="AccesstypeRadAjaxPanel" runat="server">
                        <div>
                            <asp:Label ID="AccessTypeErrmsg" runat="server" Text="" EnableViewState="false" ForeColor="Red"></asp:Label>
                            <telerik:RadGrid ID="AccessTypeRadGrid" runat="server" Width="550px"
                                AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False"
                                DataSourceID="AccessTypeSqlDataSource" GroupPanelPosition="Top"
                                CellSpacing="-1" GridLines="Both"
                                AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
                                AllowAutomaticDeletes="True" OnPreRender="AccesstypeRadDataForm_PreRender" OnItemCommand="AccessTypeRadGrid_ItemCommand" OnItemDeleted="AccesstypeRadGrid_ItemDeleted">
                                <ClientSettings AllowKeyboardNavigation="true"></ClientSettings>
                                <MasterTableView DataKeyNames="AccessTypeuid" EditMode="InPlace" CommandItemDisplay="Bottom" HorizontalAlign="NotSet" AutoGenerateColumns="False">
                                    <EditFormSettings>
                                        <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                                            UniqueName="EditCommandColumn1">
                                        </EditColumn>
                                    </EditFormSettings>
                                    <Columns>
                                        <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn" ItemStyle-Width="20px" Reorderable="True" FooterStyle-Width="20px" HeaderStyle-Width="20px">
                                        </telerik:GridEditCommandColumn>
                                        <telerik:GridBoundColumn DataField="AccessTypeuid" DataType="System.Int32" FilterControlAltText="Filter AccessTypeuid id column" HeaderText="AccessType Uid"
                                            SortExpression="AccessTypeuid" UniqueName="AccessTypeuid" Visible="false" ReadOnly="True">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="AccessType" HeaderText="Access Type"  SortExpression="AccessType" UniqueName="AccessType" FilterControlAltText="Filter AccessType column">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridNumericColumn DataField="SortOrder" HeaderText="Sort Order"  SortExpression="SortOrder" UniqueName="SortOrder" FilterControlAltText="Filter Sort Order column" DataType="System.Int32" NumericType="Number" MaxLength="3">
                                        </telerik:GridNumericColumn>
                                        <telerik:GridCheckBoxColumn DataField="Active" HeaderText="Active" SortExpression="Active" UniqueName="Active" FilterControlAltText="Filter Active column" ReadOnly="False" Visible="True" DataType="System.Boolean" >
                                        </telerik:GridCheckBoxColumn>
                                        <telerik:GridButtonColumn ConfirmText="Delete this Access Type?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" HeaderText="Delete" HeaderStyle-Width="50px" ButtonType="ImageButton" CommandName="Delete" Text="Delete" UniqueName="DeleteColumn">
                                            <HeaderStyle Width="50px" />
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                    <HeaderStyle Height="50px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                    <ItemStyle VerticalAlign="Top" />
                                    <EditItemStyle VerticalAlign="Top" />
                                </MasterTableView>
                                <ClientSettings>
            </ClientSettings>
                            </telerik:RadGrid>
                            <asp:SqlDataSource ID="AccessTypeSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:CPMConnectionString %>"
                SelectCommand="[procAccessTypeRef_Select]" SelectCommandType="StoredProcedure"
                UpdateCommand="[procAccessTypeRef_Update]" UpdateCommandType="StoredProcedure"
                InsertCommand="[procAccessTypeRef_Insert]" InsertCommandType="StoredProcedure"
                DeleteCommand="[procAccessTypeRef_Delete]" DeleteCommandType="StoredProcedure"
                >
                </asp:SqlDataSource>
                        </div>
                    </telerik:RadAjaxPanel>
                </telerik:RadPageView>
               </telerik:RadMultiPage>

     

    protected void EmployerRadGrid_ItemCommand(object sender, GridCommandEventArgs e)
            {
                if (e.CommandName == "Edit" || e.CommandName == "InitInsert")
                {
                    EmployerRadGrid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = false;
                    var ofctab = ReferencesRadTabStrip.FindTabByText("Offices");
                    ofctab.Enabled = false;
                }
                else
                {
                    EmployerRadGrid.MasterTableView.CommandItemSettings.ShowAddNewRecordButton = true;
                }
            }
            protected void EmployerRadDataForm_PreRender(object sender, EventArgs e)
            {
                var ofctab = ReferencesRadTabStrip.FindTabByText("Offices");
                if (utls.isGridinEditMode(sender) == true)
                {
                    utls.HideEditandDeleteCommandButtons(sender);
                    ofctab.Enabled = false;
                }
     
                 
                 
            }
            protected void EmployerRadGrid_ItemDeleted(object sender, GridDeletedEventArgs e)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
                RadGrid grd = (RadGrid)sender;
                String Rowname = dataItem[grd.Columns[2].UniqueName].Text;
                if (e.Exception != null)
                {
                    e.ExceptionHandled = true;
                    EmpErrmsg.Text = "The " + grd.Columns[2].UniqueName + ", " + Rowname + " cannot be deleted. Reason: " + e.Exception.Message;
                }
            }

    I have similar events for all grids. In prerender I am trying to disable one tab in the above code.
    I tried doing it on all tabs by looping and indivdually which is not working.
    What I am trying to achieve here is when an item is in edit mode in any grid I want to disable all the tabs so that users can not perform any action in other grids until the current Edit action completed.
    Hope this will give you more understabding of what I am trying to achieve and provide a solution to me.

  5. Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 06 Feb 2015 Link to this post

    Hello,

    You are not able to update the RadTabStrip due to the fact that the RadGrid is wrapped in the RadAjaxPanel and the RadTabStrip is outside the RadAjaxPanel.

     In this case you can try three approaches you if you want to do that:
    1. You can wrap both, the RadTabStrip and the RadGrid in a RadAjaxPanel.
    2. You can use RadAjaxManager and set the RadGrid to update the RadTabStrip.
    3. Not to use Ajax.
    Please, find attached a sample project. I have modified your code slightly and commented out the RadAjaxPanel to make it work (third approach of the above-mentioned options). It demonstrates how a tab in a RadTabStrip is disabled, when an item in RadGrid is in edit mode. Note how we use the OfficeRadGrid_EditCommand event handler to access a tab and change its Enabled property. This event fires when a user clicks on an Edit button in the RadGrid.

    Regards,
    Ivan Danchev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top