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

keyboard focus does not transfer to radgrid popup edit form

5 Answers 191 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Clayton
Top achievements
Rank 1
Clayton asked on 28 Dec 2010, 06:35 PM
When a popup edit form is displayed by clicking either 'add item' or 'edit' on a radgrid, keyboard focus is not transfered to the edit form's controls. Focus stays with the radgrid, so when I hit enter when the popup is shown (even after typing in a textbox in the popup), then instead of submitting the edit form, it tries to delete a non-existent item from the grid

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Dec 2010, 05:42 AM
Hello Clayton,

Try the following code snippet which shows how to set focus to control in PopUp editform.
ASPX:
<MasterTableView CommandItemDisplay="Top" DataKeyNames="EmployeeID" EditMode="PopUp">
    <Columns>
        <telerik:GridBoundColumn UniqueName="FirstName" DataField="FirstName" HeaderText="FirstName">
        </telerik:GridBoundColumn>
    </Columns>
</MasterTableView>

C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
   {
     if (e.Item is GridEditableItem && e.Item.IsInEditMode)
       {
           GridEditableItem item = (GridEditableItem)e.Item;
           TextBox control = (TextBox)item["FirstName"].Controls[0];
           var script = String.Format("setTimeout(function(){{var c = $get('{0}'); if(c && c.focus) c.focus();}},1);", control.ClientID);
           ScriptManager.RegisterStartupScript(Page, typeof(Page), "key", script, true);
       }
   }

You can also check this documentation.
Focus the text boxes in the edit control

Thanks,
Princy.
0
Clayton
Top achievements
Rank 1
answered on 29 Dec 2010, 05:39 PM
I'm just curious, why on earth does this not happen by default when the edit popup is displayed? 99% of the time the user will want focus on the popup since he/she initiated it. I've got a very large site with dozens of radgrids, and now i'll have to modify every single one of them to get this to work properly?
0
Radoslav
Telerik team
answered on 03 Jan 2011, 11:50 AM
Hello Clayton,

I tried to reproduce the described issue but to no avail. I am sending you a simple example please check it out and let me know what differs in your case. Also I am sending you a small video which demonstrates how the example works on my side.
Looking forward for your reply.

All the best,
Radoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
0
Clayton
Top achievements
Rank 1
answered on 03 Jan 2011, 06:57 PM
I think the issue is that the modal popups are not truly 'modal'. Focus can be transfered to the radgrid that is behind the modal popup by mouse-clicking outside the popup and pressing enter. I am able to reproduce this on the example you sent me by modifying the default.aspx like this:
<telerik:RadGrid runat="server" AutoGenerateEditColumn="true" AutoGenerateDeleteColumn="true" AutoGenerateColumns="false" ID="RadGrid1">
    <MasterTableView EditMode="PopUp">
        <Columns>
            <telerik:GridBoundColumn DataField="ID" HeaderText="ID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Item" HeaderText="Item">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Date" HeaderText="Date">
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings PopUpSettings-Modal="true" ></EditFormSettings>
    </MasterTableView>
    <ClientSettings AllowKeyboardNavigation="true" KeyboardNavigationSettings-AllowSubmitOnEnter="true"></ClientSettings>
</telerik:RadGrid>

I was able to tab out of the modal popup and access other controls on the grid.

EDIT:

For some reason, when setting these two parameters on my site

<ClientSettings AllowKeyboardNavigation="true" KeyboardNavigationSettings-AllowSubmitOnEnter="true" />
I receive the following error on page load:

Webpage error details
  
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.1.4322; MS-RTC LM 8; .NET4.0C; .NET4.0E)
Timestamp: Mon, 3 Jan 2011 18:01:53 UTC
  
  
Message: Can't move focus to the control because it is invisible, not enabled, or of a type that does not accept the focus.
Line: 4265
Char: 1
Code: 0
URI: http://localhost:37385/DAMP/ScriptResource.axd?d=53cAZToWMFsTBb2JkHA27StlSYaaJ0ZyrJpEn6YzYbB4FadQ8Y2A7-UUjBitr8fypiyJNCdff2PZdP1oYIYZr3kJXLcfnC6j-KawXot28FkmrgWaaVLKLMQjETgw6rO2sU1d-A2&t=7ede2a85

0
Radoslav
Telerik team
answered on 05 Jan 2011, 10:00 AM
Hi Clayton,

Regarding your first question:
Indeed the default popup edit form of the RadGrid is not truly modal. When it is opened the user can not click on the other elements on the page, however it can move the focus by pressing TAB key. In order to have a truly modal popup you need to use the RadWindow. On the following article you could find how to edit RadGrid records with RadWindow:
http://www.telerik.com/help/aspnet-ajax/grdwindowediting.html

Regarding your second issue:
I tried to reproduce the reported problem with the latest version of Telerik.Web.UI.dll but without any success. Could you please send us a sample where we could replicate the issue in order to debug it locally and get to the source of the issue. You could open a formal support ticket from your Telerik account and attach a ZIP file there. Thus we will be able to gather more details about your scenario and to provide you a solution.
Looking forward for your reply.

Best wishes,
Radoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Grid
Asked by
Clayton
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Clayton
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or