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

Focus and Highlight newly added row

4 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nirmala
Top achievements
Rank 1
Nirmala asked on 09 Jan 2013, 08:31 PM
Hi ,

  When we add a new row (inline form) to the radgrid . How to set focus or highlight the new row.

Thanks,
Nimmy

4 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Jan 2013, 05:23 AM
Hello,

<MasterTableView >
              <Columns>
                  <telerik:GridBoundColumn DataField="ID" UniqueName="ID" HeaderText="ID">
                  </telerik:GridBoundColumn>
                  <telerik:GridBoundColumn DataField="Name" UniqueName="Name" HeaderText="Name">
                  </telerik:GridBoundColumn>
                  <telerik:GridEditCommandColumn>
                  </telerik:GridEditCommandColumn>
<telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:TextBox ID="txtTranslationText" runat="server" Height="44px"
></asp:TextBox>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
              </Columns>
          </MasterTableView>
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            if (e.Item is GridDataInsertItem)
            {
                GridEditableItem item = e.Item as GridEditableItem;
                (item["ID"].Controls[0] as TextBox).Focus();
                (item.FindControl("txtTranslationText") as TextBox).Focus();
            }
        }
  
    }


Thanks,
Jayesh Goyani
0
Shinu
Top achievements
Rank 2
answered on 10 Jan 2013, 05:30 AM
Hi,

You can make the inserted row selected with reference to this code library. Also you can set focus in the controls as shown below.
C#:
protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
    {
        GridEditFormInsertItem item=(GridEditFormInsertItem)e.Item;
        TextBox txt = (TextBox)item["UniqueName"].Controls[0];
        txt.Focus();
    }
}

Thanks,
Shinu
0
Nirmala
Top achievements
Rank 1
answered on 10 Jan 2013, 02:07 PM
Hi,

I tried both of your suggestions none of them worked. My grid has Template columns not bound columns. 

Thanks,
Nimmy
0
Jayesh Goyani
Top achievements
Rank 2
answered on 11 Jan 2013, 05:20 AM
Hello,

I have update my previous post.

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Nirmala
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Shinu
Top achievements
Rank 2
Nirmala
Top achievements
Rank 1
Share this question
or