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

Focus edit item template items

3 Answers 62 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anzar
Top achievements
Rank 2
Anzar asked on 05 Feb 2013, 09:30 AM
Hi,
How to set focus to telerik rad date picker, that resides in telerik rad grid as edit item template using javascript?.

Thanks & Regards
Anzar.M
Software Engineer
SBN // Technologics
Ernakulam. 

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Feb 2013, 10:24 AM
Hi,

Try the following code to achieve your scenario.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
        {
            GridEditFormItem item = (GridEditFormItem)e.Item;
            RadDatePicker pkr1 = (RadDatePicker)item.FindControl("RadDatePicker1");
            RadGrid1.Controls.Add(new LiteralControl("<script type='text/javascript'>window['pkr'] = '" + pkr1.ClientID + "';</script>"));
        }
}
JS:
$(document).ready(function () {
     var pkr = $find(window['pkr']);
        pkr.get_dateInput().focus();
    });

Thanks,
Princy
0
Anzar
Top achievements
Rank 2
answered on 05 Feb 2013, 10:47 AM
Hi Princy,
This is not working. Please provide another solution.

Thanks & Regards
Anzar.M
Software Engineer
SBN // Technologics
Ernakulam.
0
Eyup
Telerik team
answered on 08 Feb 2013, 09:28 AM
Hello Anzar,

The RadDatePicker is a special case because it has two editor control and you could not call just the focus() function. You need to be more specific which element you want to focus.

Please check out the attached web site which demonstrates two approaches, one to show directly the RadDatePicker popup so the user is able to choose directly the date. And in the commented section you could use the code to focus the Dateinput so the user is able to type the date by itself.

You can use the following topic to access the generated picker in edit mode:
( Section Accessing controls in edit/insert mode )
http://www.telerik.com/help/aspnet-ajax/grid-accessing-cells-and-rows.html

I hope this helps. Please give it a try and let me know about the result.

All the best,
Eyup
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Grid
Asked by
Anzar
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Anzar
Top achievements
Rank 2
Eyup
Telerik team
Share this question
or