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

RadGrid TemlateColumn OnRowDataBound

1 Answer 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chandan Dey
Top achievements
Rank 1
Chandan Dey asked on 12 Apr 2014, 01:42 PM
Hi,

While accessing control which is present in item template, from “OnRowDataBound” client event, it seems that after returning 11th items, it could not able to find rest of the items.

I am wondering why It could not found control in item template after 11th items and started returning null.

I have attached sample project for your reference
Please refer the following function in sample project.

function onGridRowBound(sender, args) {
       cnt++; var btn = args.get_item().findElement("RadTextBox1");
 btn.value = args.get_dataItem().Text;
}

Once “cnt” is greater than 11, suddenly it stared returns null of "btn" reference.

I have add my code here,

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>

<!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">
<head runat="server">
<title></title>
<telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
<form id="form1" runat="server">
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
</Scripts>
</telerik:RadScriptManager>
<script type="text/javascript">
function pageLoad() {
var data = [{ Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }, { Text: "TEXT" }];
var mtv = $find('<%=RadGrid1.ClientID %>').get_masterTableView();
mtv.set_dataSource(data);
mtv.dataBind();
}
function gridCommand(sender, args) {
//
}
var cnt = 0;
function onGridRowBound(sender, args) {
cnt++;

var btn = args.get_item().findElement("RadTextBox1");
btn.value = args.get_dataItem().Text;
}
</script>
<telerik:RadGrid runat="server" ID="RadGrid1" AutoGenerateColumns="false">
<MasterTableView>
<Columns>
<telerik:GridTemplateColumn DataField="Text">
<ItemTemplate>
<telerik:RadTextBox ID="RadTextBox1" runat="server"/>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings>
<ClientEvents OnCommand="gridCommand" OnRowDataBound="onGridRowBound" />
</ClientSettings>
</telerik:RadGrid>
</form>
</body>
</html>


I would greatly appreciate any insight you could provide regarding the same

Thanks,
Chandan

1 Answer, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 14 Apr 2014, 04:33 AM
Hello,

Please check below link.

http://www.telerik.com/forums/gridtemplatecolumn-empty-when-radgrid-bound-with-json-data-on-client-side#LgNO3806EkyiDaMwi2K8HA
http://www.telerik.com/forums/radgrid-client-side-binding-with-more-than-100-rows#jPs72I-s9UeZZcxB-km-Fg

As per your code:
By default your page size is 10, so Radgrid creates only 11 Radtextbox for tempate column.
Either you have to set pagesize to 100, so it will creates 101 RadTextbox for tempate column. Then you have set page size 10.

As per my suggestion please create template column control dynamcally by using javascript. (As per above link).

Thanks,
Jayesh Goyani
Tags
Grid
Asked by
Chandan Dey
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Share this question
or