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

RadGrid Inline Add - Default Focus

3 Answers 84 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 10 Apr 2012, 04:48 PM
My customer would like the default focus set so when they click the add new record button the focus is set to the first textbox on the input line so they can begin typing without having to click the field first. Is this possible? I don't see any settings that would suggest so. Perhaps a sneaky code behind trick? Any tips greatly appreciated.

~Mike

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Apr 2012, 05:45 PM
Hello Mike,

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        
            GridEditableItem item = e.Item as GridEditableItem;
  
            // bound column
            (item["ID"].Controls[0] as TextBox).Focus();
  
            //textbox control in edititemtemplate in template column
            (item.FindControl("txtparent") as TextBox).Focus();
        }
}


Thanks,
Jayesh Goyani
0
Mike
Top achievements
Rank 1
answered on 10 Apr 2012, 06:06 PM
Thank you! Worked great!
0
Swati
Top achievements
Rank 1
answered on 26 Sep 2017, 06:57 AM

Hello jayesh,

I have same requirement as mentioned by Mike.  But this code dont work completely for me.

I am able to set focus  to editable textbox in-line but later immediately focus gets changed to Filter control upwards in same column. Any help for this please?

Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Swati
Top achievements
Rank 1
Share this question
or