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

[Solved] OnRowSelected Event in Firefox

6 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Raul
Top achievements
Rank 1
Raul asked on 07 Apr 2009, 02:32 PM
Hi,
I'm using a RadGrid inside a RadWindow (as a popup), to allow the user select a row that will be added on the main page.
I want to get the Key of the selected row and pass it to the main page, the code of the page that loads into RadWindow is:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="NewsSelect.aspx.cs" Inherits="SR.News.Views.NewsSelect" 
    Title="NewsSelect"  %> 
<%@ Register Assembly="Microsoft.Practices.Web.UI.WebControls" Namespace="Microsoft.Practices.Web.UI.WebControls" 
    TagPrefix="pp" %> 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml" style="height: 100%"
<head id="Head" runat="server">  
    <script type="text/javascript">             
    function GetRadWindow() 
    { 
    var oWindow = null
    if (window.radWindow) 
     oWindow = window.radWindow; 
    else if (window.frameElement.radWindow) 
     oWindow = window.frameElement.radWindow; 
    return oWindow; 
    }    
    function OnClientRowSelected(sender, eventArgs) 
    { 
    var currentWindow = GetRadWindow();     
    var newsId = eventArgs.getDataKeyValue("NewsID") 
    currentWindow.close(newsId); 
    }      
    </script> 
    <link href="../App_Themes/Default/rightcontent.css" type="text/css" rel="stylesheet" /> 
    <title>SardegnaRicerche</title> 
</head> 
<body style="height: 100%; margin: 0 auto; overflow: hidden" scroll="no"
 
     
    <form id="form1" runat="server" style="height: 100%; width: 100%; margin: 0px"
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"  
        OutputCompression="AutoDetect"
    </telerik:RadScriptManager> 
    <pp:ObjectContainerDataSource ID="odsNews" runat="server"  
        DataObjectTypeName="SRRules.Entities.News" /> 
    <telerik:RadGrid ID="grdFiles" runat="server" AutoGenerateColumns="False"  
        GridLines="None" Skin="Office2007" DataSourceID="odsNews"
<MasterTableView DataKeyNames="NewsID" DataSourceID="odsNews"  
            ClientDataKeyNames="NewsID"
<RowIndicatorColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</RowIndicatorColumn> 
 
<ExpandCollapseColumn> 
<HeaderStyle Width="20px"></HeaderStyle> 
</ExpandCollapseColumn> 
    <Columns> 
        <telerik:GridBoundColumn DataField="Priority" DataType="System.Int32" HeaderText="Priorità" 
                    ReadOnly="True" SortExpression="Priority" UniqueName="Priority"
                </telerik:GridBoundColumn> 
                <telerik:GridBoundColumn DataField="Title"  
                    HeaderText="News" UniqueName="Title" SortExpression="Title"
                </telerik:GridBoundColumn> 
                <telerik:GridDateTimeColumn DataField="StartDatePublication"  
                    HeaderText="Data pubblicazione" SortExpression="StartDatePublication" 
                    UniqueName="StartDatePublication"  DataFormatString="{0:d}" 
                    DataType="System.DateTime"
                </telerik:GridDateTimeColumn> 
                <telerik:GridDateTimeColumn DataField="EndDatePublication"  
                    HeaderText="Data scadenza" SortExpression="EndDatePublication" 
                    UniqueName="EndDatePublication" DataFormatString="{0:d}"  
                    DataType="System.DateTime"
                </telerik:GridDateTimeColumn> 
    </Columns>     
</MasterTableView> 
 
        <ClientSettings> 
            <Selecting AllowRowSelect="True" EnableDragToSelectRows="False" /> 
            <ClientEvents OnRowSelected="OnClientRowSelected" /> 
        </ClientSettings> 
 
<FilterMenu EnableTheming="True" Skin="Office2007"
<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation> 
</FilterMenu> 
    </telerik:RadGrid> 
    </form> 
</body> 
</html> 


This code work fine for IE7, however, the event doesn't get fired in Firefox3 (I tried putting a breakpoint on the function OnClientRowSelected(sender, eventArgs) (line 20) and Firefox never reaches it.

I would appreciate any help on this matter,

Regards,
Raúl Herrmann

6 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 10 Apr 2009, 02:05 PM
Hi Raul,

When you add the UniqueID of a column to the ClientDataKeyNames array of the MasterTableView or a detail GridTableView, RadGrid makes that column's value available through the getDataKeyValue() function of the GridDataItem client-side object and of the arguments for client-side event handlers that respond to item events.
You can refer to the following articles which explains how to access the key value for the selected row on the client side.
Extracting key values client-side
Keys/Values Client-side

I hope this information helps.

All the best,
Pavlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Raul
Top achievements
Rank 1
answered on 13 Apr 2009, 12:09 PM
Hi Pavlina,
thank you for your answer.
What you said is exactly what I'm doing in my code. The problem, however, is that the client event "OnRowSelected" is not fired on Firefox. (The code works fine for IE).
Any suggestions on why this may be happening would be useful,
thanks,
Raúl

0
Pavlina
Telerik team
answered on 14 Apr 2009, 07:19 AM
Hi Raul,

Unfortunately from the provided information I am not able to determine the exact source of the issue you are facing. At this point I will ask you to send us a runnable project via a support ticket. Thus I could do my best to find a quick resolution of this issue.

In the meantime you can review the following forum post, which discuss similar behavior :
ClientEvents-RowSelected is not fired in FireFox - RadCodeBlock problem

Sincerely yours,
Pavlina
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
Marco
Top achievements
Rank 1
answered on 29 Jun 2009, 10:47 AM

I'm unable to return value from radGrid  eventArgs.getDataKeyValue(primaryKey) always return null...

I'm using hiddenfield to store datakey because my controls are created dynamically.

I'm sure the datakey name is the right one and ajaxmanager its instantiated. So what could be null???


function rowDoubleClick(sender, eventArgs) 
{

                var primaryKey = document.getElementById('<%=hiddenfield.ClientID%>').value;
                var ajaxMng = $find("<%= radajax.ClientID %>");
                alert(primaryKey);
                ajaxMng.ajaxRequest("RowClicked:" + eventArgs.getDataKeyValue(primaryKey));
                alert(eventArgs.getDataKeyValue(primaryKey));
}

 
0
Marco
Top achievements
Rank 1
answered on 30 Jun 2009, 09:07 AM
i have found the solution.

To retrieve primary key value from javascript we need to define ClientDataKeyNames property of mastertableview

Ex:

RadGrid1.MasterTableView.ClientDataKeyNames = new string[] { col.varColumnName };

on markup i have defined:

 <script type="text/javascript">
            function rowDoubleClick(sender, eventArgs) 
            {
                var ajaxMng = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>");
                var primaryKey = document.getElementById('<%=hiddenfield.ClientID%>').value;
                ajaxMng.ajaxRequest("RowClicked:" + eventArgs.getDataKeyValue(primaryKey));
            }
        </script>

hiddenfield : hidden field to preserve the primary key column uniquename

I hope this help someone

0
Pavlina
Telerik team
answered on 30 Jun 2009, 04:06 PM
Hi Marco ,

I am glad that you discovered a solution which suits your needs - thank you for sharing it in this public forum thread. Thus you can help other people who are searching similar implementation.
Please do not hesitate to contact us if any issues arise.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Raul
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Raul
Top achievements
Rank 1
Marco
Top achievements
Rank 1
Share this question
or