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

Setting Tab Index on Grid 'Insert' 'Cancel' links

1 Answer 55 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg Barretta
Top achievements
Rank 1
Greg Barretta asked on 23 Jun 2010, 06:49 PM
I have a basic time entry grid, with a RadComboBox and a set of RadNumericTextBoxes. I want to be able to tab from the Combo, through the textboxes, then to the 'Insert' and 'Cancel' links that are inherent when Inserting with RadGrid. I set the tab order in the ItemDataBound event.  How can I programatically access the 'Insert' and 'Cancel' links in order to set the TabIndex for those?
protected void detailsGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
        { 
      
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            { 
             
                GridEditableItem item = e.Item as GridEditableItem; 
                RadComboBox list = item.FindControl("List1"as RadComboBox; 
 
                list.TabIndex = 10; 
                    RadNumericTextBox tb = (RadNumericTextBox)edititem["day1"].Controls[0]; 
                    tb.Width = Unit.Pixel(intSize); 
                    tb.TabIndex = 11; 
                    RadNumericTextBox tb1 = (RadNumericTextBox)edititem["day2"].Controls[0]; 
                    tb1.Width = Unit.Pixel(intSize); 
                    tb1.TabIndex = 12; 
                    RadNumericTextBox tb2 = (RadNumericTextBox)edititem["day3"].Controls[0]; 
                    tb2.Width = Unit.Pixel(intSize); 
                    tb2.TabIndex = 13; 
                    RadNumericTextBox tb3 = (RadNumericTextBox)edititem["day4"].Controls[0]; 
                    tb3.Width = Unit.Pixel(intSize); 
                    tb3.TabIndex = 14; 
                    RadNumericTextBox tb4 = (RadNumericTextBox)edititem["day5"].Controls[0]; 
                    tb4.Width = Unit.Pixel(intSize); 
                    tb4.TabIndex = 15; 
                    RadNumericTextBox tb5 = (RadNumericTextBox)edititem["day6"].Controls[0]; 
                    tb5.Width = Unit.Pixel(intSize); 
                    tb5.TabIndex = 16; 
                    RadNumericTextBox tb6 = (RadNumericTextBox)edititem["day7"].Controls[0]; 
                    tb6.Width = Unit.Pixel(intSize); 
                    tb6.TabIndex = 17;
}
                    <telerik:RadGrid runat="server" Visible="true" ID="detailsGrid" MasterTableView-EditMode="EditForms"  
                        onneeddatasource="detailsGrid_NeedDataSource" Width="100%"  AllowSorting="true" 
                        MasterTableView-CommandItemDisplay="Bottom" ShowHeader="true" AutoGenerateColumns="False" 
                         OnItemDataBound="detailsGrid_ItemDataBound" EnableLinqExpressions="false" onupdatecommand="detailsGrid_UpdateCommand" 
                         oninsertcommand="detailsGrid_InsertCommand" onitemcommand="detailsGrid_ItemCommand"
                        <MasterTableView DataKeyNames="taskName,taskID,projectid" editmode="InPlace" width="100%" > 
                         <Columns>  
                             <telerik:GridTemplateColumn UniqueName="TemplateColumn" HeaderText="Task" SortExpression="taskName"  
                                                         EditFormHeaderTextFormat="Task:<FONT COLOR=RED >  * </FONT>"  > 
                                <ItemTemplate> 
                                    <asp:Label id="Label1" runat="server" ToolTip=<%# DataBinder.Eval(Container.DataItem, "description") %>
                                    <%# DataBinder.Eval(Container.DataItem, "taskName") %> 
                                    </asp:Label> 
                               </ItemTemplate> 
                               <EditItemTemplate > 
                                   <telerik:RadComboBox id="List1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="List1_SelectedIndexChanged"  /> 
                               </EditItemTemplate> 
                             </telerik:GridTemplateColumn> 
                             <telerik:GridNumericColumn DataField="day1" DataType="System.Decimal"  /> 
                             <telerik:GridNumericColumn DataField="day2" DataType="System.Decimal" /> 
                             <telerik:GridNumericColumn DataField="day3" DataType="System.Decimal" /> 
                             <telerik:GridNumericColumn DataField="day4" DataType="System.Decimal" /> 
                             <telerik:GridNumericColumn DataField="day5" DataType="System.Decimal" /> 
                             <telerik:GridNumericColumn DataField="day6" DataType="System.Decimal" /> 
                             <telerik:GridNumericColumn DataField="day7" DataType="System.Decimal" /> 
                              
                         </Columns>     
                    </MasterTableView> 
                    </telerik:RadGrid> 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Jun 2010, 07:57 AM
Hello Greg,

You can try the following code snippet to access the insert and cancel links and set thier TabIndex.

ASPX:
 
<MasterTableView EditMode="InPlace" CommandItemDisplay="Bottom"
    <Columns> 
         <telerik:GridTemplateColumn> 
          <EditItemTemplate> 
              <telerik:RadComboBox ID="List1" runat="server" AutoPostBack="true" /> 
          </EditItemTemplate> 
         </telerik:GridTemplateColumn> 
         <telerik:GridNumericColumn UniqueName="day1" DataType="System.Decimal" /> 
        <telerik:GridEditCommandColumn> 
        </telerik:GridEditCommandColumn> 
    </Columns> 
</MasterTableView> 

C#:
 
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem item = e.Item as GridEditableItem; 
            RadComboBox list = item.FindControl("List1"as RadComboBox; 
            list.TabIndex = 10; 
            RadNumericTextBox tb = (RadNumericTextBox)item["day1"].Controls[0]; 
            tb.TabIndex = 11; 
            LinkButton btnInsert = (LinkButton)item.FindControl("PerformInsertButton"); 
            btnInsert.TabIndex = 12; 
            LinkButton btnCancel = (LinkButton)item.FindControl("CancelButton"); 
            btnCancel.TabIndex = 13; 
        } 
    } 

Thanks,
Princy.
Tags
Grid
Asked by
Greg Barretta
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or