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

make the tab seleted by default

1 Answer 13 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Sudhakar
Top achievements
Rank 1
Sudhakar asked on 30 Dec 2014, 10:22 AM
Hi Team,

I have a grid with some rows in it. When I expand each row I am displaying the 3 tabs.
I wanted to implement the following scenario.

1)Based on some predefined values(we defining them in enumerations.cs file)need to select the one of the tab by default.
If the enum value is zero need to make the  second tab selected by default and if the enum value is 1 need to make the third tab selected by default.

I am using the telerik dll version of 2014.3.1216.45 and implementing batch editing functionality.

ASPX CODE
-----------------
<telerik:RadGrid ID="DischargeRadGrid"   OnItemDataBound="DsichargeRadGridFormat_OnItemDataBound" runat="server" AutoGenerateColumns="false"
                            CssClass="TransferGridPanel" Height="363px" Width="548px" OnItemCommand="DischargeRadGrid_ItemCommand"
                            OnBatchEditCommand="DischargeRadGrid_BatchEditCommand" OnNeedDataSource="DischargeRadGrid_NeedDataSource" OnPreRender="DischargeRadGrid_PreRender" OnItemCreated="DischargeRadGrid_ItemCreated">
                           <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch"  HierarchyLoadMode="ServerOnDemand" DataKeyNames="Discharge_ID">
                            <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewDelivery" />
                               <BatchEditingSettings EditType="Cell" />
                            <NestedViewTemplate>
                             <telerik:RadTabStrip runat="server" ID="DischargeTabStrip" MultiPageID="DischargeMultipage" ClickSelectedTab="True"
                                 SelectedIndex="0" OnTabClick="DischargeTabStip_TabClick">
                        <Tabs>
                            <telerik:RadTab runat="server" Text="Details" PageViewID="DischargePageViewDetails">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="DischargePageViewCompartments">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Products" PageViewID="DischargePageViewProducts">
                            </telerik:RadTab>
                        </Tabs>
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage runat="server" ID="DischargeMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                        <telerik:RadPageView runat="server" ID="DischargePageViewDetails">
                            <div class="contactWrap">
                                <table cellpadding="0" cellspacing="0">
                                <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_ShipTo" Text='ShipTo:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_ShipToValue" Enabled="false"></asp:TextBox></td>
                                    </tr>
                                    <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_SiteName" Text='Name:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_SiteNameValue" Enabled="false"></asp:TextBox></td>
                                </tr>
                                <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_Address" Text='Address:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_AddressValue" Enabled="false" TextMode="MultiLine"></asp:TextBox></td>
                                    </tr>                                    <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_SplInstruction" Text='SpecialInstructions:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_SplInstructionValue" Enabled="false"></asp:TextBox></td>
                                    </tr>                                    <tr>
                                    <td>
                                            <asp:Label runat="server" ID="lbl_PONumber" Text='PONumber:' Font-Bold="true"></asp:Label></td>
                                    <td>
                                            <asp:TextBox runat="server" ID="txt_PONumberValue"  Enabled="false"></asp:TextBox>
                                            <asp:ImageButton ImageUrl="~/images/PenEditIcon.gif" runat="server" ID="btn_editPONumber"  OnClick="btn_editPONumber_Click"></asp:ImageButton>                                    </td>
                                </tr>
                                 
                                   
                            </table>
                            </div>
                        </telerik:RadPageView>
                        <telerik:RadPageView runat="server" ID="DischargePageViewCompartments">
                            <telerik:RadGrid ID="CompartmentLevelDischargeRadGrid" runat="server" AutoGenerateColumns="false"
                                CssClass="TransferGridPanel" Height="233px" Width="475px" OnItemDataBound="CompartmentLevelDischargeRadGrid_ItemDataBound" 
                                OnBatchEditCommand="CompartmentLevelDischargeRadGrid_BatchEditCommand" OnNeedDataSource="CompartmentLevelDischargeRadGrid_NeedDataSource"
                                 OnPreRender="CompartmentLevelDischargeRadGrid_PreRender">
                               
                                <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="CompartmentIndex">
                                    <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add LineItem" />
                               <BatchEditingSettings EditType="Cell" />
                                    <Columns>
                                        <telerik:GridTemplateColumn HeaderText="Comp No." HeaderStyle-Width="50px" UniqueName="ItemNo" DataField="CompartmentIndex">
                                            <ItemTemplate>
                                                <%# Eval("CompartmentIndex") %>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <telerik:RadComboBox runat="server" ID="ddlDischargeCompartment" OnLoad="ddlDischargeCompartments" Width="50px">
                                                </telerik:RadComboBox>
                                            </EditItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn HeaderText="Planned Product" HeaderStyle-Width="70px" UniqueName="PlannedDischargeProd" DataField="PlannedProductName" ReadOnly="true" InsertVisiblityMode="AlwaysVisible">
                                            <ItemTemplate>
                                                <%# Eval("PlannedProductName") %>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <telerik:RadComboBox runat="server" ID="ddlPlannedDischargeProduct" OnLoad="ddlPlannedProductDischarge" Width="70px">
                                                </telerik:RadComboBox>
                                            </EditItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn HeaderText="Actual Product" HeaderStyle-Width="70px" UniqueName="ActualDischargeProd" DataField="ActualProductName">
                                            <ItemTemplate>
                                                <%# Eval("ActualProductName") %>
                                            </ItemTemplate>
                                            <EditItemTemplate>
                                                <telerik:RadComboBox runat="server" ID="ddlActualDischargeProduct" OnLoad="ddlActualProductDischarge" Width="70px">
                                                </telerik:RadComboBox>
                                            </EditItemTemplate>
                                        </telerik:GridTemplateColumn>
                                       
                                                        <telerik:GridTemplateColumn HeaderText="Planned Quantity" HeaderStyle-Width="50px" UniqueName="PlannedDischargeQty" DataField="PlannedQuantity" ReadOnly="true" InsertVisiblityMode="AlwaysVisible">
                                                            <ItemTemplate>
                                                                <%# Eval("PlannedQuantity") %>
                                                            </ItemTemplate>
                                                            <EditItemTemplate>
                                                               <telerik:RadTextBox ID="plannedDischargeQty" runat="server" DataField="PlannedQuantity" HeaderStyle-Width="30px" HeaderText="Planned Quantity" UniqueName="PlannedDischargeQty">
                                                             </telerik:RadTextBox>
                                                            </EditItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                        <telerik:GridTemplateColumn HeaderText="Actual Quantity" HeaderStyle-Width="50px" UniqueName="ActualDischargeQty" DataField="ActualQuantity">
                                                            <ItemTemplate>
                                                                <%# Eval("ActualQuantity") %>
                                                            </ItemTemplate>
                                                            <EditItemTemplate>
                                                               <telerik:RadTextBox  ID="ActualDischargeQty" runat="server"  DataField="ActualQuantity" HeaderStyle-Width="30px" HeaderText="Actual Quantity" UniqueName="ActualDischargeQty">
                                                             </telerik:RadTextBox>
                                                            </EditItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                       
                                        <telerik:GridTemplateColumn HeaderText="Planned Tank" HeaderStyle-Width="50px" UniqueName="PlannedTank" DataField="TankIndex" ReadOnly="true" InsertVisiblityMode="AlwaysVisible">
                                                            <ItemTemplate>
                                                                <%# Eval("TankIndex") %>
                                                            </ItemTemplate>
                                                            <EditItemTemplate>
                                                               <telerik:RadTextBox runat="server" ID="plannedTank"  DataField="TankIndex" HeaderStyle-Width="30px" HeaderText="Planned Tank" UniqueName="PlannedTank">
                                                               </telerik:RadTextBox>
                                                            </EditItemTemplate>
                                           
                                       
                                                        </telerik:GridTemplateColumn>
                                       
                                        <telerik:GridTemplateColumn HeaderText="Actual Tank" HeaderStyle-Width="50px" UniqueName="ActualTank" DataField="ActualTankIndex">
                                                            <ItemTemplate>
                                                                <%# Eval("ActualTankIndex") %>
                                                            </ItemTemplate>
                                                            <EditItemTemplate>
                                                               <telerik:RadTextBox runat="server" ID="actualTank" DataField="ActualTankIndex" HeaderStyle-Width="30px" HeaderText="Actual Tank" UniqueName="ActualTank">
                                                             </telerik:RadTextBox>
                                                            </EditItemTemplate>
                                                        </telerik:GridTemplateColumn>
                                        <telerik:GridBoundColumn UniqueName="LeftOnBoard" DataField="LOB" HeaderText="LOB" ReadOnly="true">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="Adjustment" DataField="Adjustment" HeaderText="Adjustment" ReadOnly="true">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                        </telerik:RadPageView>
                    <telerik:RadPageView runat="server" ID="DischargePageViewProducts">
                    <telerik:RadGrid ID="ProductLevelDischargeRadGrid" runat="server" AutoGenerateColumns="false"
                                CssClass="TransferGridPanel" Height="233px" Width="475px" OnItemDataBound="ProductLevelDischargeRadGrid_ItemDataBound"
                          OnNeedDataSource="ProductLevelDischargeRadGrid_NeedDataSource">
                            <MasterTableView ShowHeadersWhenNoRecords="true">
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="PlannedDischargeProd" DataField="PlannedProductName" HeaderText="Planned Product" Visible="false">
                                        </telerik:GridBoundColumn>                                       
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeProd" DataField="ActualProductName" HeaderText="Actual Product">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PlannedDischargeQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                        </telerik:GridBoundColumn>                                       
                                        <telerik:GridBoundColumn UniqueName="ActualTank" DataField="ActualTankIndex" HeaderText="Actual Tank">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="CaluculatedDifference" DataField="CaluculatedDifference" HeaderText="Caluculated Difference">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PreDip" DataField="PreDip" HeaderText="PreDip">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PostDip" DataField="PostDip" HeaderText="PostDip">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PreSMR" DataField="PreSMR" HeaderText="SMR Start">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PostSMR" DataField="PostSMR" HeaderText="SMR End">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="LeftOnBoard" DataField="LOB" HeaderText="LOB">
                                    </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="Adjustment" DataField="Adjustment" HeaderText="Adjustment">
                                    </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                    </telerik:RadPageView>
                    </telerik:RadMultiPage>
                    </NestedViewTemplate>                                <Columns>
                                    <telerik:GridBoundColumn  UniqueName="DeliveryNo" DataField="Discharge_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="ShipTo"
                                        DataField="Site_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="ShipToName"
                                        DataField="SiteAddress" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="DischargeStart"
                                        DataField="DischargeStartTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="DischargeEnd"
                                        DataField="DischargeEndTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="PlannedFlag"
                                        DataField="Planned" Display="false">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>                           
                           
                            <Scrolling AllowScroll="true"/>
                              <ClientEvents OnBatchEditOpened="OnBatchEditOpened" /> 
                            </ClientSettings>
                        </telerik:RadGrid>
ASPX.CS CODE
------------ protected void DischargeRadGrid_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            dischargeID = Convert.ToInt64(item["DeliveryNo"].Text);
            Session[_selectDischargeId] = dischargeID;
        }
       
        //loading compartment level discharge data
        List<DischargeDetailExtraEntity> dischargeTabListinstance = new List<DischargeDetailExtraEntity>();
        dischargeTabListinstance = dischargeDetailManager.GetDischargeDetailWSListByDischargeId(dischargeID);
        Session["_storeCompartmentDischargeTable"] = dischargeTabListinstance;        //loading compartment level discharge data
        List<DischargeDetailExtraEntity> ProductTabinstance = new List<DischargeDetailExtraEntity>();
        ProductTabinstance = dischargeDetailManager.GetDischargeDetailByDischargeIdAtProductlevel(dischargeID);
        Session["_storeProductDischargeTable"] = ProductTabinstance;    }
protected void DischargeTabStip_TabClick(object sender, RadTabStripEventArgs e)
    {
       
            e.Tab.PageView.Selected = true;
            string selectedtabindex = e.Tab.Text;
            Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
            Int64 discharge = 0;
            discharge = Convert.ToInt64(Session[_selectDischargeId].ToString());
            switch (selectedtabindex)
            {
                case "Details":
                    {
                        RadPageView page = (RadPageView)e.Tab.PageView;                        List<DischargeEntity> dischargeDetails = new List<DischargeEntity>();
                        dischargeDetails = dischargeManager.GetDischargeDetailsByDischargeId(discharge);//.GetDischargeByID(discharge);
                        Session[_sesDischargeList] = dischargeDetails;
                        TextBox txtShipTo = (TextBox)page.FindControl("txt_ShipToValue");
                        TextBox txtSiteName = (TextBox)page.FindControl("txt_SiteNameValue");
                        TextBox txtAddress = (TextBox)page.FindControl("txt_AddressValue");
                        TextBox txtSplInstructions = (TextBox)page.FindControl("txt_SplInstructionValue");
                        TextBox txtPONumber = (TextBox)page.FindControl("txt_PONumberValue");
                        if (dischargeDetails.Count > 0)
                        {
                            txtShipTo.Text = dischargeDetails[0].Site_ID.ToString();
                            txtSiteName.Text = dischargeDetails[0].SiteName;
                            txtAddress.Text = dischargeDetails[0].SiteAddress + dischargeDetails[0].SiteName2;
                            txtSplInstructions.Text = dischargeDetails[0].DeliveryWindow;
                            txtPONumber.Text = dischargeDetails[0].PONumber.ToString();
                        }
                        else
                        {
                            txtShipTo.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                            txtSiteName.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                            txtAddress.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                            txtSplInstructions.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                            txtPONumber.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                        }                        break;
                    }
                case "Compartments":
                    {
                        DischargeCompartmentGrid();
                        (e.Tab.PageView.FindControl("CompartmentLevelDischargeRadGrid") as RadGrid).Rebind();
                        break;
                    }
                case "Products":
                    {
                        DischargeProductGrid();
                        (e.Tab.PageView.FindControl("ProductLevelDischargeRadGrid") as RadGrid).Rebind();
                        break;
                    }
            }
       
    }

Regards,
Sudhakar.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 01 Jan 2015, 01:54 PM
Hello Sudhakar,

Can you please refer to answer from 29-Dec-2014 in ticket with ID: 876775, where I have explained in details how you could achieve such behavior:

"Since your HierarchyLoadMode is set to ServerOnDemand, once you expand an item you can get reference to the NestedViewTemplate withing the server-side OnItemCommand event handler and depending on your enumeration, to select a specific RadTab in the RadTabStrip control..."


Best Regards,
Konstantin Dikov
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.

 
Tags
TabStrip
Asked by
Sudhakar
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or