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

[Solved] Pop Up editor Shows on enter press

2 Answers 190 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Drew
Top achievements
Rank 2
Drew asked on 19 Nov 2009, 04:51 PM
I need a good workaround for an Issue I found with the radgrid.

When I press enter while focus is anywhere on my page (in another control or wherever) focus is automatically transferred to the insertCommand button in the grid header which causes the popup editor to show up.

Here is how I declare the grid in markup:

<asp:UpdatePanel ID="upnlGrid4" runat="server" > 
    <ContentTemplate> 
        <telerik:RadGrid ID="gvFirmInfo" runat="server" Width="550px"
            <MasterTableView EditMode="PopUp" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add Location"  
                         ShowHeadersWhenNoRecords="true" ShowHeader="false"  
                         NoMasterRecordsText="information is not available. <br/> Please click 'Add Location' to add the contact information for each location" 
                         AlternatingItemStyle-BackColor="White" AlternatingItemStyle-BorderStyle="Solid"  
                         AlternatingItemStyle-BorderWidth="1px" AlternatingItemStyle-BorderColor="#C9C4D1" 
                         ItemStyle-BackColor="#E0E0E0" ItemStyle-BorderColor="#FFFFFF" ItemStyle-BorderStyle="Solid" 
                         ItemStyle-BorderWidth="0px" BorderColor="#C9C4D1" BorderWidth="1px" BorderStyle="Solid" GridLines="None"
                           
                <EditFormSettings InsertCaption="Add Location" CaptionDataField="" PopUpSettings-Modal="true"/> 
                <Columns> 
                    <telerik:GridBoundColumn DataField="rowId" HeaderText="Row ID" UniqueName="rowId" 
                        Visible="False" EditFormColumnIndex="-1"
                    </telerik:GridBoundColumn> 
                                                                                                                                        
                                        
                    <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn"
                        <ItemTemplate> 
                            <asp:CheckBox id="ChkDelete" AutoPostBack="false" runat="server"></asp:CheckBox> 
                            <asp:Label runat="server" Text="Delete Location"></asp:Label> 
                        </ItemTemplate> 
                    </telerik:GridTemplateColumn> 
                     
                    <telerik:GridButtonColumn CommandName="Edit" Text="Edit" UniqueName="columnEdit" ItemStyle-Width="35px"
                    </telerik:GridButtonColumn>                    
                </Columns>                      
                                                                                                                                                          
            </MasterTableView> 
        </telerik:RadGrid> 
    </ContentTemplate>  
</asp:UpdatePanel> 


My grids are dynamic and are built using advanced binding like so:

Protected Sub gvFirmInfo_NeedDataSource(ByVal source As ObjectByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles gvFirmInfo.NeedDataSource 
        Dim sqlString As String = "" 
        Dim sqlparam(2) As SqlParameter 
        Dim ds As New DataSet 
        Dim dr As SqlDataReader = Nothing 
 
        Try 
            Conn = New SqlConnection(ConfigurationManager.ConnectionStrings("****").ConnectionString) 
            Conn.Open() 
 
            SetParam(sqlparam(0), "@recId", Data.SqlDbType.Int, 4, m_rec_id) 
            SetParam(sqlparam(1), "@recType", Data.SqlDbType.Char, 2, m_rec_type) 
 
            sqlString = "select...***" 
 
            ds = SqlHelper.ExecuteDataset(Conn, Data.CommandType.Text, sqlString, sqlparam) 
            gvFirmInfo.DataSource = ds 
 
        Catch ex As Exception 
            '***** 
        End Try 


The problem occurs in IE 8 as well as Firefox 3.015

What do you all recommend for working around this issue?

Cheers!

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Nov 2009, 10:59 AM
Hello Drew,

Make sure that keyboardnavigation for the grid is disabled which may otherwise cause a similar behavior. If that does not help probably you can cancel the enter key press event, refering to the following help document :
Cancel Enter/arrow key press when navigating with the keyboard

Thanks
Princy.
0
Drew
Top achievements
Rank 2
answered on 20 Nov 2009, 03:17 PM
Thanks for the suggestion,

I tried setting AllowKeyboardNavigation="false"  But that did not accomplish what I was trying to do.

I have a radNumericTextbox on my page above the grid, when focus is inside of that text box and I press enter, focus is Immediately transferred to the radgrid and the modal pop-up editor appears.

It happens no matter which control has focus, or if no control has focus.

I have worked around it half-way by adding this javascript:

<script type="text/javascript"
    function stopRKey(evt) { 
        var evt = (evt) ? evt : ((event) ? event : null); 
        var node = (evt.target) ? evt.target : ((evt.srcElement) ? evt.srcElement : null); 
        if ((evt.keyCode == 13) && (node.type == "text")) { return false; } 
    } 
 
    document.onkeypress = stopRKey;  
 
</script> 

But the only problem is , edit mode still fires off when I do a keypress anywhere on the page outside of a control.

Any other Ideas?

~D
Tags
Grid
Asked by
Drew
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Drew
Top achievements
Rank 2
Share this question
or