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

ClientEvents OnRowCreated undefined

9 Answers 206 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kelvin Lush
Top achievements
Rank 1
Kelvin Lush asked on 10 Sep 2009, 01:26 PM
Hi,
I'm using a grid control with a GridClientSelectColumn and I'm trying to prevent the whole row being set to the selected item backcolor. I just need to have the checkbox checked.

I thought I could do this by using the ClientEvents OnRowCreated. However, when I do this I get the error
"Microsoft JScript runtime error: 'RowCreated' is undefined"

I have tried putting the script into a RadScriptManager but it makes no difference.

The code I have is:

<

script type="text/javascript">
function RowCreated(sender, eventArgs) {debugger;}
</script>

 

 

 

 

 


The grid's client settings are:

 

<ClientSettings>
<Selecting AllowRowSelect="True" EnableDragToSelectRows="False" />
<ClientEvents OnRowCreated="RowCreated"></ClientEvents>
</ClientSettings>

Do you have any suggestions?

Thanks,
 Kelvin

9 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 11 Sep 2009, 06:59 AM
Hello Kelvin,

I don't see anything wrong. Please check for other Javascript errors, which may cause this one. Here is a working example:

<%@ Page Language="C#" %> 
<%@ Import Namespace="System.Data" %> 
<%@ 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"> 
 
<script runat="server"
 
protected void RadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e) 
    DataTable dt = new DataTable(); 
    DataRow dr; 
    int colsNum = 4
    int rowsNum = 2
    string colName = "Column"
 
    for (int j = 1; j <= colsNum; j++) 
    { 
        dt.Columns.Add(String.Format("{0}{1}", colName, j)); 
    } 
 
    for (int i = 1; i <= rowsNum; i++) 
    { 
        dr = dt.NewRow(); 
 
        for (int k = 1; k <= colsNum; k++) 
        { 
            dr[String.Format("{0}{1}", colName, k)] = String.Format("{0}{1} Row{2}", colName, k, i); 
        } 
        dt.Rows.Add(dr); 
    } 
 
    (sender as RadGrid).DataSource = dt
 
</script> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"
<meta http-equiv="content-type" content="text/html;charset=utf-8" /> 
<title>RadControls for ASP.NET AJAX</title> 
</head> 
<body> 
<form id="form1" runat="server"
<asp:ScriptManager ID="ScriptManager1" runat="server" /> 
 
<telerik:RadGrid 
    ID="RadGrid1" 
    runat="server" 
    OnNeedDataSource="RadGrid_NeedDataSource"
    <ClientSettings> 
        <ClientEvents OnRowCreated="RowCreated" /> 
    </ClientSettings> 
</telerik:RadGrid> 
 
<script type="text/javascript"
 
function RowCreated(sender, args) 
    alert("RowCreated fired"); 
 
</script> 
 
</form> 
</body> 
</html> 



If you need further assistance, please send a complete web page, as the one above.


Sincerely yours,
Dimo
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Saranya
Top achievements
Rank 1
answered on 21 Jan 2011, 12:05 PM
Hi Telerik,

The row.Index in the OnRowCreated event and the column.Index in the OnColumnCreated event results in undefined value. [vs 2008 rad controls 2010 Q3]. It is giving grid object instead of the row object/column object.In the alert you have shown in the code snippet doesnt pop up the rowindex. Below is the code snippet, plz help.
<form id="form1" runat="server">
   <div>
       <asp:ScriptManager ID="mainScriptManager" runat="server" />
       <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
           <script type="text/javascript">
                function RowCreated(rowObject)
                
                alert("Row with Index: " + rowObject.Index + " was created");
                }
                function ColumnCreated(columnObject)
                
                alert("Column with Index: " + columnObject.Index + " was created");
                }
           </script>
       </telerik:RadScriptBlock>
       <asp:UpdatePanel ID="mainUpdatePanel" runat="server">
           <ContentTemplate>
               <telerik:RadGrid ID="mainRadGrid" runat="server" OnNeedDataSource="mainRadGrid_NeedDataSource"
                   AutoGenerateColumns="false" Skin="Office2007">
                   <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
                   </HeaderContextMenu>
                   <MasterTableView>
                       <Columns>
                           <telerik:GridBoundColumn DataField="OrderId" HeaderText="Order Id" UniqueName="OrderId">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="CustomerId" HeaderText="Customer Id" UniqueName="CustomerId">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="Company" HeaderText="Company" UniqueName="Company">
                           </telerik:GridBoundColumn>
                           <telerik:GridBoundColumn DataField="Date" HeaderText="Date" UniqueName="Date">
                           </telerik:GridBoundColumn>
                       </Columns>
                   </MasterTableView>
                   <ClientSettings>
                       <ClientEvents OnRowCreated="RowCreated" OnColumnCreated="ColumnCreated" ></ClientEvents>
                   </ClientSettings>
                   <FilterMenu EnableImageSprites="False">
                   </FilterMenu>
               </telerik:RadGrid>
           </ContentTemplate>
       </asp:UpdatePanel>
   </div>
   </form>

Regards,
Saranya S

0
Iana Tsolova
Telerik team
answered on 21 Jan 2011, 12:19 PM
Hello Saranya,

Refer to the below article for more information on how you can get reference to the grid item in the OnRowCreated client-side event:
http://www.telerik.com/help/aspnet-ajax/grid_onrowcreated.html

All the best,
Iana
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
Saranya
Top achievements
Rank 1
answered on 21 Jan 2011, 01:00 PM
Hi Lana,

Here the eventArgs.get_gridDataItem() give out of stack space error and the eventArgs._gridDataItem is null. Anything to do with the Grid data binding? I want the corresponding row object on the event OnRowCreated and the column object on the OnColumnCreated event.

Regards,
Saranya S
0
Iana Tsolova
Telerik team
answered on 24 Jan 2011, 03:21 PM
Hi Saranya,

I tested the scenario in the attached sample, but everything works fine on my side. I can properly access the grid items in the OnRowCreated event. Can you check it and let me know what differs in your case?

Best wishes,
Iana
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
Saranya
Top achievements
Rank 1
answered on 28 Jan 2011, 12:42 PM
The application needs to be Built with Framework 3.5 and Telerik ASP.NET RadControls Q3 2010. The details mentioned were even available to me in VS2005. Please do the needy.

Regards,
Saranya S
0
Iana Tsolova
Telerik team
answered on 31 Jan 2011, 05:01 PM
Hi Saranya,

Attached is the converted sample.

Regards,
Iana
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
Saranya
Top achievements
Rank 1
answered on 01 Feb 2011, 07:44 AM
Hi Lana,

Thanks for the effort. But the Telerik.Web.UI used in that is not the latest one. The latest Assembly of Telerik .Web.UI throws exception at eventArgs.get_gridDataItem() for the same code. Please check and update.

Thanks,
Saranya S
0
Iana Tsolova
Telerik team
answered on 02 Feb 2011, 02:07 PM
Hello Saranya,

Indeed, the example was using the Q3 2010 version of the controls. However I updated it to Q3 2010 SP2 which is the latest official version but still the eventArgs.get_gridDataItem() returns the proper GridDataItem object.
Can you check it? If the issue persists on your end, let me know which browser you are using.

Kind regards,
Iana
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
Kelvin Lush
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Saranya
Top achievements
Rank 1
Iana Tsolova
Telerik team
Share this question
or