Why GridCreated sometimes takes 2 parameters like in this case, and sometimes it doesn't take any parameter. I'm trying to use it with 2 parameters.
Thanks.
function GridCreated(sender, args)
{
var scrollArea = sender.GridDataDiv;
var parent = $get("gridContainer");
var gridHeader = sender.GridHeaderDiv;
scrollArea.style.height = parent.clientHeight - gridHeader.clientHeight + "px";
}
</script>
<div style="height: 500px; width: 800px" id="gridContainer">
<telerik:RadGrid
id="RadGrid1" runat="server"
AutoGenerateColumns="true"
DataSourceID="AccessDataSource1">
<ClientSettings>
<Scrolling
AllowScroll="true"
ScrollHeight="300px"
UseStaticHeaders="true" />
<ClientEvents OnGridCreated="GridCreated" />
</ClientSettings>
</telerik:RadGrid>
</div>
Thanks.
function GridCreated(sender, args)
{
var scrollArea = sender.GridDataDiv;
var parent = $get("gridContainer");
var gridHeader = sender.GridHeaderDiv;
scrollArea.style.height = parent.clientHeight - gridHeader.clientHeight + "px";
}
</script>
<div style="height: 500px; width: 800px" id="gridContainer">
<telerik:RadGrid
id="RadGrid1" runat="server"
AutoGenerateColumns="true"
DataSourceID="AccessDataSource1">
<ClientSettings>
<Scrolling
AllowScroll="true"
ScrollHeight="300px"
UseStaticHeaders="true" />
<ClientEvents OnGridCreated="GridCreated" />
</ClientSettings>
</telerik:RadGrid>
</div>
5 Answers, 1 is accepted
0
Hello PG,
I'm not sure in which scenario this function will not take any parameters - can you post an example?
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I'm not sure in which scenario this function will not take any parameters - can you post an example?
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0
PG
Top achievements
Rank 1
answered on 10 Jul 2008, 03:29 PM
Vlad,
Here is the other example I found. The problem I'm having is that I'm trying to use 2 parameters so I can use "sender".
Here is the other example I found. The problem I'm having is that I'm trying to use 2 parameters so I can use "sender".
<rad:radgrid id="RadGrid1" AllowSorting="True" AllowPaging="True" EnableAJAX="True" EnableAJAXLoadingTemplate="True"
runat="server">
<ClientSettings>
<ClientEvents OnGridCreated="GridCreated" OnRequestStart="RequestStart"></ClientEvents>
</ClientSettings>
</rad:radgrid>
<style type="text/css">
.MasterTableView
{
display : none;
}
</style>
<script type="text/javascript">
var shouldShowTemplate = true;
//hook the GridCreated event
function GridCreated()
{
if(shouldShowTemplate)
{
var template = document.getElementById(this.ClientID + "_LoadingTemplate");
if (template != null)
{
template.style.display = "";
template.align = "center";
var grid = this;
var hideTemplate = function()
{
grid.MasterTableView.Control.className = "";
template.style.display = "none";
};
window.setTimeout(hideTemplate, 2000);
}
}
}
//The above script will not be executed when a normal request is performed
function RequestStart()
{
shouldShowTemplate = false;
}
</script>
runat="server">
<ClientSettings>
<ClientEvents OnGridCreated="GridCreated" OnRequestStart="RequestStart"></ClientEvents>
</ClientSettings>
</rad:radgrid>
<style type="text/css">
.MasterTableView
{
display : none;
}
</style>
<script type="text/javascript">
var shouldShowTemplate = true;
//hook the GridCreated event
function GridCreated()
{
if(shouldShowTemplate)
{
var template = document.getElementById(this.ClientID + "_LoadingTemplate");
if (template != null)
{
template.style.display = "";
template.align = "center";
var grid = this;
var hideTemplate = function()
{
grid.MasterTableView.Control.className = "";
template.style.display = "none";
};
window.setTimeout(hideTemplate, 2000);
}
}
}
//The above script will not be executed when a normal request is performed
function RequestStart()
{
shouldShowTemplate = false;
}
</script>
0
PG
Top achievements
Rank 1
answered on 10 Jul 2008, 03:39 PM
To be more accurate, my question is actually: Why when I user 2 parameters the "sender" parameter is null (or 'undefined'). Thi is my code:
function GridCreated(sender, eventArgs) |
{ |
var gridElement = sender.get_element(); |
var elementsToUse = []; |
inputs = gridElement.getElementsByTagName("input"); |
for (var i = 0; i < inputs.length;i++) |
{ |
if(inputs[i].type.toLowerCase() == "hidden") |
{ |
continue; |
} |
Array.add(elementsToUse, inputs[i]); |
inputs[i].onchange = TrackChanges; |
} |
dropdowns = gridElement.getElementsByTagName("select"); |
for (var i = 0; i < dropdowns.length;i++) |
{ |
dropdowns[i].onchange = TrackChanges; |
} |
setTimeout(function(){if(elementsToUse[0])elementsToUse[0].focus();},100); |
} |
function TrackChanges(e) |
{ |
hasChanges = true; |
} |
</script> |
</HEAD> |
<body class="sectionPanel" MS_POSITIONING="GridLayout"> |
<form id="Form1" method="post" runat="server"> |
<TABLE class="sectionPanel" id="TableDownload" cellSpacing="0" cellPadding="0" width="600px" |
border="0"> |
<TR> |
<TD><radg:radgrid id="documentRadGrid" runat="server" AutoGenerateColumns="False" Width="100%" Skin="myFile" |
GridLines="None" |
ShowStatusBar="True" AllowSorting="True" AllowPaging="True" |
AllowAutomaticUpdates="True" |
> |
<footerstyle CssClass="GridFooter_Default"></footerstyle> |
<pagerstyle CssClass="GridPager_Default"></pagerstyle> |
<groupheaderitemstyle CssClass="GroupHeader_Default"></groupheaderitemstyle> |
<filteritemstyle CssClass="GridFilterRow_Default"></filteritemstyle> |
<alternatingitemstyle CssClass="GridAltRow_Default"></alternatingitemstyle> |
<commanditemstyle CssClass="GridCommandRow_Default"></commanditemstyle> |
<selecteditemstyle CssClass="SelectedRow_Default"></selecteditemstyle> |
<headerstyle CssClass="GridHeader_Default"></headerstyle> |
<exportsettings> |
<PDF PageFooterMargin="" PageRightMargin="" PageLeftMargin="" PageBottomMargin="" PageHeaderMargin="" |
PageWidth="8.5in" PageHeight="11in" PageTopMargin=""></PDF> |
</exportsettings> |
<activeitemstyle CssClass="ActiveRow_Default"></activeitemstyle> |
<mastertableview CssClass="MasterTable_Default" GridLines="None"> |
<rowindicatorcolumn SortAscImageUrl="~/RadControls/Grid/Skins/Default/SortAsc.gif" SortDescImageUrl="~/RadControls/Grid/Skins/Default/SortDesc.gif" |
FilterImageUrl="~/RadControls/Grid/Skins/Default/Filter.gif" Visible="False"> |
<itemstyle CssClass="ResizeItem_Default"></itemstyle> |
<headerstyle CssClass="ResizeHeader_Default" Width="20px"></headerstyle> |
</rowindicatorcolumn> |
<columns> |
<radg:gridboundcolumn SortAscImageUrl="~/RadControls/Grid/Skins/Default/SortAsc.gif" SortDescImageUrl="~/RadControls/Grid/Skins/Default/SortDesc.gif" |
FilterImageUrl="~/RadControls/Grid/Skins/Default/Filter.gif" UniqueName="documentId" DataField="documents" |
HeaderText="Doc ID"> |
<headerstyle HorizontalAlign="Center"></headerstyle> |
<itemstyle HorizontalAlign="Center"></itemstyle> |
</radg:gridboundcolumn> |
<radg:gridtemplatecolumn SortAscImageUrl="~/RadControls/Grid/Skins/Default/SortAsc.gif" SortDescImageUrl="~/RadControls/Grid/Skins/Default/SortDesc.gif" |
FilterImageUrl="~/RadControls/Grid/Skins/Default/Filter.gif" UniqueName="Pages" HeaderText="Pages"> |
<headerstyle HorizontalAlign="Center"></headerstyle> |
<itemstyle HorizontalAlign="Center"></itemstyle> |
<itemtemplate> |
<div align="center"> |
<asp:RadioButtonList id="pagesRadiobuttonlist" runat="server" Width="100px" RepeatDirection="Horizontal"> |
<asp:ListItem Value="All" Selected="True">All</asp:ListItem> |
<asp:ListItem Value="Page Range">Range</asp:ListItem> |
</asp:RadioButtonList> |
</div> |
</itemtemplate> |
</radg:gridtemplatecolumn> |
<radg:GridTemplateColumn DataField="pagerange" HeaderText="Page Range" UniqueName="pagerange" SortAscImageUrl="~/RadControls/Grid/Skins/Default/SortAsc.gif" SortDescImageUrl="~/RadControls/Grid/Skins/Default/SortDesc.gif" FilterImageUrl="~/RadControls/Grid/Skins/Default/Filter.gif"> |
<ItemTemplate> |
<A id="ECFId1" style="CURSOR: hand" border="0" > |
<SPAN class="t1 blue bold arial"> |
<%# DataBinder.Eval(Container.DataItem, "pagerange")%> |
</SPAN></A> |
</ItemTemplate> |
</radg:GridTemplateColumn> |
<radg:gridboundcolumn SortAscImageUrl="~/RadControls/Grid/Skins/Default/SortAsc.gif" SortDescImageUrl="~/RadControls/Grid/Skins/Default/SortDesc.gif" |
FilterImageUrl="~/RadControls/Grid/Skins/Default/Filter.gif" UniqueName="pagerange" DataField="pagerange" |
HeaderText="Page Range"> |
<headerstyle HorizontalAlign="Center"></headerstyle> |
<itemstyle HorizontalAlign="Center"></itemstyle> |
</radg:gridboundcolumn> |
<radg:gridboundcolumn SortAscImageUrl="~/RadControls/Grid/Skins/Default/SortAsc.gif" SortDescImageUrl="~/RadControls/Grid/Skins/Default/SortDesc.gif" |
FilterImageUrl="~/RadControls/Grid/Skins/Default/Filter.gif" UniqueName="docformat" DataField="docformat" |
HeaderText="Doc Format"> |
<headerstyle HorizontalAlign="Center"></headerstyle> |
<itemstyle HorizontalAlign="Center"></itemstyle> |
</radg:gridboundcolumn> |
</columns> |
<commanditemsettings RefreshImageUrl="~/RadControls/Grid/Skins/Default/Refresh.gif" AddNewRecordImageUrl="~/RadControls/Grid/Skins/Default/AddRecord.gif"></commanditemsettings> |
</mastertableview> |
<ClientSettings> |
<ClientEvents OnRowClick="RowClick" OnRowDblClick="RowDblClick" |
OnGridCreated="GridCreated" /> |
</ClientSettings> |
<itemstyle CssClass="GridRow_Default"></itemstyle> |
<edititemstyle CssClass="GridEditRow_Default"></edititemstyle> |
<filtermenu SelectedImageUrl="~/RadControls/Grid/Skins/Default/SelectedMenu.gif" NotSelectedImageUrl="~/RadControls/Grid/Skins/Default/NotSelectedMenu.gif"></filtermenu> |
</radg:radgrid> |
0
PG
Top achievements
Rank 1
answered on 10 Jul 2008, 04:14 PM
Is the sender parameter null because I'm not using a datasource? I'm manually inserting the records to the grid in the OnLoad event.
So how can I solve this? Thanks.
So how can I solve this? Thanks.
0
Accepted
Hi PG,
It seems that you have our old "Classic" RadGrid. The arguments can be used with our new RadGrid for ASP.NET AJAX.
All the best,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
It seems that you have our old "Classic" RadGrid. The arguments can be used with our new RadGrid for ASP.NET AJAX.
All the best,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center