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

Radgrid is null at clientside pageload

1 Answer 151 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 14 Dec 2011, 06:16 AM

Hi all,
Im using radgrid in my application.
I try to get the object of radgrid in pageload at clientside(javascript),but im getting grid as null.
If I try in sample page , I'm able to get the grid.
whats wrong in my code can u please tell me as early as possible. Its urgent for me.
Here is my code.

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
         <script type="text/javascript">
             function pageLoad() {
                 var grd = $find("<%= grdHistory.ClientID %>");//giving null
             }     
            </script
           </telerik:RadCodeBlock
  
<form id="form1" runat="server">    
    <telerik:RadScriptManager ID="scrptMangr1" runat="server" />
    <asp:Table ID="tblFilter" runat="server" CssClass="headerTable" Height="70px" width="758px">
        <asp:TableRow>
            <asp:TableCell>
                <asp:Label ID="begnDatelbl" runat="server" Text="Begin Date:" CssClass="normalLable" />
            </asp:TableCell><asp:TableCell>
                <telerik:RadDateTimePicker ID="begnDate" runat="server" ClientEvents-OnDateSelected="begnDate_DateSelected"
                    Skin="Outlook" Width="165px" Height="12px" CssClass="datetimePicker" >
                    <Calendar runat="server" ID="Calendar1">
                        <SpecialDays>
                            <telerik:RadCalendarDay Repeatable="Today" ItemStyle-BackColor="Orange" />
                        </SpecialDays>
                    </Calendar>
                    <DateInput ID="DateInput1" runat="server" DateFormat="MM/dd/yyyy HH:mm:ss" />
                    <TimeView ID="TimeView1" runat="server" TimeFormat="HH:mm:ss" />
                    <HideAnimation Type="Slide" />
                    <ShowAnimation Type="Slide" />
                    <DatePopupButton ImageUrl="../images/Cal_iconj.gif" HoverImageUrl="../images/Cal_iconj.gif" />
                    <TimePopupButton ImageUrl="../images/watch.gif" HoverImageUrl="../images/watch.gif" />
                </telerik:RadDateTimePicker>
            </asp:TableCell><asp:TableCell>
                <asp:Label ID="endDatelbl" runat="server" Text="End Date:" CssClass="normalLable" />
            </asp:TableCell><asp:TableCell>
                <telerik:RadDateTimePicker ID="endDate" runat="server" Skin="Outlook" ClientEvents-OnDateSelected="endPicker_DateSelected"
                    Width="165px" Height="12px" CssClass="datetimePicker" >
                    <Calendar runat="server" ID="Calendar2">
                        <SpecialDays>
                            <telerik:RadCalendarDay Repeatable="Today" ItemStyle-BackColor="Orange" />
                        </SpecialDays>
                    </Calendar>
                    <DateInput ID="DateInput2" runat="server" DateFormat="MM/dd/yyyy HH:mm:ss" />
                    <TimeView ID="TimeView2" runat="server" TimeFormat="HH:mm:ss" />
                    <HideAnimation Type="Slide" />
                    <ShowAnimation Type="Slide" />
                    <DatePopupButton ImageUrl="../images/Cal_iconj.gif" HoverImageUrl="../images/Cal_iconj.gif" />
                    <TimePopupButton ImageUrl="../images/watch.gif" HoverImageUrl="../images/watch.gif" />
                </telerik:RadDateTimePicker>
            </asp:TableCell><asp:TableCell>
                <asp:Label ID="serveritylbl" runat="server" Text="Severity:" CssClass="normalLable" />
            </asp:TableCell><asp:TableCell>
                <asp:DropDownList ID="serverityddl" runat="server" CssClass="dropDwnlist" Height="16%"
                    Width="120px">
                    <asp:ListItem Value="All" Selected="True">Show All</asp:ListItem>
                    <asp:ListItem Value="Low">Low</asp:ListItem>
                    <asp:ListItem Value="Minor">Minor</asp:ListItem>
                    <asp:ListItem Value="Major">Major</asp:ListItem>
                </asp:DropDownList>
            </asp:TableCell><asp:TableCell></asp:TableCell></asp:TableRow><asp:TableRow>
            <asp:TableCell>
                <asp:Label ID="sourcelbl" runat="server" Text="Source:" CssClass="normalLable" />
            </asp:TableCell><asp:TableCell>
                <asp:DropDownList ID="sourceddl" runat="server" CssClass="dropDwnlist" Width="120px" DataTextField="SourceId"
                    DataValueField="SourceId" AppendDataBoundItems="true" Height="16%">
                </asp:DropDownList>
            </asp:TableCell><asp:TableCell>
                <asp:Label ID="productNamelbl" runat="server" Text="Product:" CssClass="normalLable" />
            </asp:TableCell><asp:TableCell>
                <asp:DropDownList ID="productddl" runat="server" CssClass="dropDwnlist" DataTextField="ProductName" Width="120px"
                    DataValueField="ProductName" AppendDataBoundItems="true" Height="16%">
                    <asp:ListItem Value="All" Selected="True">Show All</asp:ListItem>
                </asp:DropDownList>
            </asp:TableCell><asp:TableCell>
                <asp:Label ID="alarmCodelbl" runat="server" Text="Alarm Code:" CssClass="normalLable" />
            </asp:TableCell><asp:TableCell>
                <asp:DropDownList ID="alarmddl" runat="server" CssClass="dropDwnlist" DataTextField="AlarmCode"
                    DataValueField="AlarmCode" AppendDataBoundItems="true" Height="16%" Width="120px">
                </asp:DropDownList>
            </asp:TableCell><asp:TableCell>
                <asp:ImageButton ID="imgbtnGenerateRpt" runat="server" ImageUrl="~/images/disablebtn.gif"
                    Enabled="false"  OnClick="imgbtnGenerateRpt_Click" Width="90px"
                    Height="20px" />
            </asp:TableCell></asp:TableRow></asp:Table><div class="line"></div>            
    <asp:Panel ID="pnlExport" runat="server">
  
        <table style="overflow: auto; width:99%; height: 28px;">
            <tr>
                <td style="background-image: url('../images/lblBackGround.gif'); background-repeat: no-repeat;
                    overflow: auto;">
                    <asp:Label ID="lblHeader" runat="server" Text="Alarm History" CssClass="logReportlbl" />  <asp:ImageButton ID="gridHistoryBtnExcel" ToolTip="Excel" ImageUrl="../images/excel_20x20.png"
                        OnClick="btnExcelHistory_Click" runat="server" Height="16px" />  <asp:ImageButton ID="gridHistoryBtnCsv" ToolTip="Csv" ImageUrl="../images/csv_20x20.png"
                        OnClick="btnCSVHistory_Click" runat="server" Height="16px" />  <asp:ImageButton ID="btnPrintHistory" ImageUrl="../images/PrintBlue.PNG" OnClick="btnPrintHistory_Click"
                        ToolTip="Print" runat="server"  />
                      <asp:ImageButton ID="gridHistoryBtnHelp" ToolTip="Help" ImageUrl="../images/help_20x20.png"
                        runat="server" Height="16px" OnClientClick="window.open('//Help/ApplicationHelp.htm');" />
                </td>
                <td  style="text-align:right;">
        <asp:Label ID="dateLbl" runat="server"  CssClass="italicLbl"/>
       </td>
            </tr>
            <tr>
       <td  colspan="2" style="text-align:right;">
       <asp:Label  ID="filterLbl" runat="server" Text="Source:All,Product:All,Alarm Code:All,Severity:All" CssClass="italicLbl"/>
       </td>
       </tr>
        </table>
          
    </asp:Panel>
    <asp:Timer ID="refrshTimer" runat="server" OnTick="refrshTimer_Tick" />  
         
    <asp:Panel ID="pnlAlarmSummaryVisibility" runat="server">
  
     <div class="line" style=" margin-top:5px;"></div>
        <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server"  loadingpanelid="LoadingPanel1">
            <telerik:RadGrid ID="grdHistory" Style="border: 0" runat="server" AllowSorting="true" Width="98%"
                PageSize="5" AllowPaging="true" CssClass="gridView1" AutoGenerateColumns="false"
                OnItemDataBound="grdHistory_DataBound" OnNeedDataSource="grdHistory_NeedDataSource"
                OnItemCommand="grdHistory_ItemCommand" OnSortCommand="grdHistory_SortCommand"
                OnExcelMLExportRowCreated="grdHistory_ExcelMLExportRowCreated" OnExcelMLExportStylesCreated="grdHistory_ExcelMLExportStylesCreated">
                <SortingSettings EnableSkinSortStyles="false" />
                <MasterTableView TableLayout="Fixed" AllowMultiColumnSorting="false" ShowHeadersWhenNoRecords="false">
                <ItemStyle  CssClass="rgRow" Font-Names="Arial" Font-Size="12px" ForeColor="#000000"/>
                <AlternatingItemStyle Font-Names="Arial" Font-Size="12px" ForeColor="#000000"/>
                <HeaderStyle CssClass="actLogGrdheader" />
                <ItemStyle />
                    <PagerStyle Mode="NumericPages" />
                    <Columns>
                        <telerik:GridBoundColumn DataField="SetDateTime" SortExpression="SetDateTime" HeaderText="Date/Time"                             
                            HeaderStyle-Width="70px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Status" SortExpression="Status" HeaderText="Incident"
                              ItemStyle-Width="50px"
                            HeaderStyle-Width="50px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="SourceId" SortExpression="SourceId" HeaderText="Source"
                             ItemStyle-Width="80px"
                            HeaderStyle-Width="80px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="ProductName" SortExpression="ProductName" HeaderText="Product"
                             ItemStyle-Width="80px"
                            HeaderStyle-Width="80px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="AlarmInfo" SortExpression="AlarmInfo" HeaderText="Description" UniqueName="AlarmInfo"
                             ItemStyle-Width="260px"
                            HeaderStyle-Width="260px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Severity" SortExpression="Severity" HeaderText="Severity"
                             ItemStyle-Width="60px"
                            HeaderStyle-Width="60px">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="AlarmDateTime" Visible="false">
                        </telerik:GridBoundColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings>
                    <%-- <Scrolling AllowScroll="True" ScrollHeight="100px" UseStaticHeaders="True" SaveScrollPosition="True" >
                </Scrolling>--%>
                </ClientSettings>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
  
        <div class="line" style="margin-top: -2px"></div>        
    </asp:Panel>
    <asp:Label  ID="norecMsgLbl" runat="server" ForeColor="#153b77" Font-Size="15" Font-Names="Arial" style="position:relative; top:150px; left:25%; right:40%;" />          
    <%--</ContentTemplate>
    </asp:UpdatePanel>--%>   
    <telerik:RadAjaxLoadingPanel  id="LoadingPanel1" runat="server"  >
<asp:Image ID="img" runat="server" ImageUrl="~/images/loading3.gif" BackColor="Beige"
                        AlternateText="Loading" Style="top: 100px; left: 307px; position: absolute; height: 17px;
                        width: 67px" />
</telerik:RadAjaxLoadingPanel>
  
    <asp:Label runat="server" ID="lblError"  ForeColor="Red" Font-Bold="true" Font-Size="12px" Font-Names="Arial"></asp:Label><p>
         </p><telerik:RadToolTipManager ID="RadToolTipManager1" runat="server" Skin="Telerik"
             Animation="None" Position="BottomRight" EnableShadow="true"  AutoTooltipify="true">
          </telerik:RadToolTipManager>  
        </form></body></html>
I have this problem in 6 pages,please help me out asap

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 14 Dec 2011, 06:34 AM
Hello,

I have tried the same but no avail and it worked as expected at my end. I am using version 2011, 2, 915, 35.
JS:
function pageLoad()
 {
    var grd = $find("<%= RadGrid1.ClientID %>");
 }

Thanks,
Princy.
Tags
Grid
Asked by
Ram
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or