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

How to focus on first control Of Rad GRID

4 Answers 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
prathyusha
Top achievements
Rank 1
prathyusha asked on 13 Sep 2011, 11:41 PM

Hi,

When I click on addNewItem Of  rad Frid.
How to place the Focus on First Control of inserted
If column  is GridBound Column like as follows

 

<telerik:GridBoundColumn DataField="Address1" UniqueName="Address1" HeaderText="<%$ Resources:lbl_Employee_Address1 %> " ShowFilterIcon="false"

 

 

EditFormColumnIndex="0" Visible="false" >

 

 

</telerik:GridBoundColumn>

 



Could some one please help me regarding this.

I really appreciate it.
Thanks in advance

--Prathyusha

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Sep 2011, 05:18 AM
Hello Prathyusha,

Try the following code snippet to achieve your scenario.
C#:
protected void rad_ItemCreated(object sender, GridItemEventArgs e)
{
   if (e.Item is GridEditFormItem && e.Item.IsInEditMode && e.Item.OwnerTableView.IsItemInserted)
      {
         GridEditFormItem item = (GridEditFormItem)e.Item;
         TextBox txt = (TextBox)item["EmployeeID"].Controls[0];
         txt.Focus();
      }
}

Thanks,
Princy.
0
prathyusha
Top achievements
Rank 1
answered on 14 Sep 2011, 02:32 PM
Thank you princy for immediate response.
I tried this solution
But focus is not staying , when I clicked on the Add new item.
Here is the code
If there is any mistake please let me know.

<

 

telerik:GridBoundColumn DataField="BankName" UniqueName="BankName" HeaderText="<%$ Resources:lbl_Employee_BankName %>"

 

 

EditFormColumnIndex="0">

 

 

</telerik:GridBoundColumn>

 


if

 

(e.Item is GridEditFormItem && e.Item.IsInEditMode && e.Item.OwnerTableView.IsItemInserted)

 

{

 

GridEditFormItem item = (GridEditFormItem)e.Item;

 

 

TextBox txt = (TextBox)item["BankName"].Controls[0];

 

 

// EmployeeBankAccountRadGrid.Controls.Add(new LiteralControl

 

 

//(String.Format("<script type='text/javascript'>document.getElementById('{0}').focus();document.getElementById('{0}').scrollIntoView();</script>", item.FindControl("BankName").ClientID)));

 

txt.Focus();

}

For template column it is working, If I use javascript code which in the above code. But same code is not working for  GridBound column.

Could some one please suggest either of way to fix this issue.
Thank you.

0
Shinu
Top achievements
Rank 2
answered on 19 Sep 2011, 01:24 PM
Hello Prathyusha,

Try the following code library approach to access the Template column control form client side.
Retrieving grid editor value client side.

Thanks,
Shinu.
0
prathyusha
Top achievements
Rank 1
answered on 19 Sep 2011, 03:28 PM
Thank you so much shinu,
Is there any way we can do same thing for GridBoundColumn.

If any one have idea, how do it for Gridbound column, Please suggest me.


Thanks
Prathyusha
Tags
Grid
Asked by
prathyusha
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
prathyusha
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or