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

how to set tab index only in radgrid edit item template

2 Answers 280 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dhamodharan
Top achievements
Rank 1
Dhamodharan asked on 02 Feb 2011, 12:42 PM
Hi,

I have using radgrid in my application. when i clicked edit button i have set tab index to first control in edit template like (textbox). and also tab index align also fine. tab index going update and cancel. it is fine. then i clicked tab it will go to again text box like only with in edit item template.

how to set tab index with edit item template.

I have attached image please help me.

Thanks,
Dhamu.

2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 07 Feb 2011, 11:15 AM
Hello Dhamu,

Here is a sample code snippet which shows how to achieve this.
ASPX:
<Columns>
    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
    </telerik:GridEditCommandColumn>
    <telerik:GridTemplateColumn>
        <ItemTemplate>
            <asp:Label ID="Label1" runat="server" Text='<%#Eval("EmployeeID") %>'></asp:Label>
        </ItemTemplate>
        <EditItemTemplate>
            txt1:
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>
    <telerik:GridTemplateColumn>
        <ItemTemplate>
            <asp:Label ID="Label2" runat="server" Text='<%#Eval("FirstName") %>'></asp:Label>
        </ItemTemplate>
        <EditItemTemplate>
            txt2:
            <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
        </EditItemTemplate>
    </telerik:GridTemplateColumn>
</Columns>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem item = e.Item as GridEditFormItem;
            TextBox txtbox = (TextBox)item.FindControl("TextBox1");
            txtbox.Focus();
            LinkButton btnCancel = (LinkButton)item.FindControl("CancelButton");
            btnCancel.Attributes.Add("onkeydown", "test('"+txtbox.ClientID+"');");
        }
    }

Java Script:
<script type="text/javascript">
        var txtbox;
        function test(txtboxID) {
            txtbox = document.getElementById(txtboxID);
            setTimeout("txtbox.focus();", 200);
         }
    </script>

Thanks,
Princy.
0
Dhamodharan
Top achievements
Rank 1
answered on 07 Feb 2011, 12:26 PM
Thank you so much.

It is working fine.


Thanks,
Dhamu
Tags
Grid
Asked by
Dhamodharan
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Dhamodharan
Top achievements
Rank 1
Share this question
or