$find is not working

6 posts, 0 answers
  1. Bharat
    Bharat avatar
    25 posts
    Member since:
    Jan 2014

    Posted 31 Jan 2014 Link to this post

    I am using the following statement declared below

    $find("<%= RadGrid1.ClientID %>").get_masterTableView();

    to find radgrid from my page but $find("<%= RadGrid1.ClientID %>") returning as null.

    Please let me know how to resolve this issue.

    Thanks
    Bharat
  2. Jayesh Goyani
    Jayesh Goyani avatar
    2733 posts
    Member since:
    May 2010

    Posted 31 Jan 2014 in reply to Bharat Link to this post

    Hello,

    Can you please provide your code snippet?

    Thanks,
    Jayesh Goyani
  3. Bharat
    Bharat avatar
    25 posts
    Member since:
    Jan 2014

    Posted 31 Jan 2014 in reply to Jayesh Goyani Link to this post

     //<![CDATA[
                function pageLoad(sender, eventArgs) {

                    var tableView = $find("<%= GridView1.ClientID %>").get_masterTableView();
                    $find("<%= RadAjaxLoadingPanel1.ClientID %>").show("<%= GridView1.ClientID %>");
                    PageMethods.GetData(parseInt($find("<%= hdnParentCompany_Id.ClientID %>")), parseInt($find("<%= hdnNamespace.ClientID %>")),
                                                      parseInt($find("<%= hdnUserLevel.ClientID %>")), parseInt($find("<%= hdnUserId.ClientID %>")),
                                                      parseInt($find("<%= hdnStartDate.ClientID %>")), parseInt($find("<%= hdnEndDate.ClientID %>")),
                                                      "0","","", tableView.get_sortExpressions().toString(), 0 , tableView.get_pageSize(), tableView.get_filterExpressions().toList(),
                        updateGrid);

                   //PageMethods.GetCount(tableView.get_filterExpressions().toList(), updateVirtualItemCount);
                }

                function RadGrid1_Command(sender, args) {
                    args.set_cancel(true);

                    var pageSize = sender.get_masterTableView().get_pageSize();

                    var sortExpressions = sender.get_masterTableView().get_sortExpressions();
                    var filterExpressions = sender.get_masterTableView().get_filterExpressions();

                    var currentPageIndex = sender.get_masterTableView().get_currentPageIndex();

                    if (args.get_commandName() == "Filter")
                        currentPageIndex = 0;

                    var sortExpressionsAsSQL = sortExpressions.toString();

                    $find("<%= RadAjaxLoadingPanel1.ClientID %>").show("<%= GridView1.ClientID %>");

                    PageMethods.GetData(currentPageIndex * pageSize, pageSize, sortExpressionsAsSQL, filterExpressions.toList(), updateGrid);

                    if (args.get_commandName() == "Filter") {
                        PageMethods.GetCount(filterExpressions.toList(), updateVirtualItemCount);
                    }
                }

                function updateGrid(result) {
                    var tableView = $find("<%= GridView1.ClientID %>").get_masterTableView();
                    tableView.set_dataSource(result);
                    tableView.dataBind();

                    $find("<%= RadAjaxLoadingPanel1.ClientID %>").hide("<%= GridView1.ClientID %>");
                }

                function updateVirtualItemCount(result) {
                    var tableView = $find("<%= GridView1.ClientID %>").get_masterTableView();
                    tableView.set_virtualItemCount(result);
                }

                function RadGrid1_RowDataBound(sender, args) {
                    var radTextBox1 = args.get_item().findControl("LastName"); // find control
                    radTextBox1.set_value(args.get_dataItem()["LastName"]);

                    // conditional formatting
                    args.get_item().get_cell("TitleOfCourtesy").style.fontWeight = (args.get_dataItem()["TitleOfCourtesy"] == "Dr.") ? "bold" : "normal";
                }
                //]]>

    <telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" AutoGenerateColumns="false"
                    AllowFilteringByColumn="true" PageSize="100" AllowPaging="true" AllowSorting="true"
                    OnPreRender="GridView_OnPreRender" CellSpacing="1" Style="padding: 1px;" 
                    Skin="Default" >
                    <ItemStyle Wrap="false"></ItemStyle>
                    <ClientSettings>
                        <Selecting AllowRowSelect="False" />
                        <Scrolling AllowScroll="true" ScrollHeight="500px" />
                        <ClientEvents OnHierarchyExpanding="GridViewOnHierarchyExpending" />
                    </ClientSettings>
                    <ExportSettings Excel-Format="Html" ExportOnlyData="true" IgnorePaging="true" OpenInNewWindow="true">
                    </ExportSettings>
                    <MasterTableView Name="AllMailSentDetails" CommandItemDisplay="Top" TableLayout="Fixed">
                        <HeaderStyle Font-Size="14px" />
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column" Visible="True" />
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column" Visible="True" />
                        <SortExpressions>
                            <telerik:GridSortExpression FieldName="Content_Viewed" SortOrder="Ascending" />
                        </SortExpressions>
                        <CommandItemTemplate>
                            <asp:Button ID="ExportMasterDataButton" runat="server" CommandName="ExportMasterData"
                                ClientIDMode="Static"></asp:Button>
                        </CommandItemTemplate>
                        <Columns>
                            <telerik:GridBoundColumn DataField="First_Name_Sender" HeaderText="Sender First Name"
                                UniqueName="FirstNameSender" ItemStyle-Width="130px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Last_Name_Sender" SortExpression="Last_Name_Sender"
                                HeaderText="Sender Last Name" UniqueName="LastNameSender" ItemStyle-Width="100px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Email_Sender" HeaderText="Sender Email" UniqueName="EmailSender"
                                ItemStyle-Width="100px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="First_Name" HeaderText="Recipient First Name"
                                UniqueName="FirstName" ItemStyle-Width="100px">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Last_Name" HeaderText="Recipient Last Name" UniqueName="LastName"
                                ItemStyle-Width="100px">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn DataField="Email_Address" SortExpression="Email_Address"
                                HeaderText="Recipient Email Address" ItemStyle-Width="100px" UniqueName="EmailAddress">
                                <ItemTemplate>
                                    <a onclick="viewVirtualContact(<%#Eval("contact_id")%>,<%#Eval("isvirtualcontact")%>)">
                                        <%# Eval("Email_Address") %></a>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="Company" HeaderText="Company" UniqueName="Company"
                                ItemStyle-Width="100px">
                                <%--   <FilterTemplate>
                                    <div class="Drop-down-child">
                                        <uc1:CompanyFilter ID="CompanyFilter1" runat="server" />
                                    </div>
                                </FilterTemplate>--%>
                                <ItemTemplate>
                                    <%# Eval("Company")%>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridBoundColumn DataField="Create_Date_Std" HeaderText="Send Date" UniqueName="Create_Date_Std"
                                ItemStyle-Width="100px">
                            </telerik:GridBoundColumn>
                            <telerik:GridTemplateColumn DataField="Video_content_sent" SortExpression="Video_content_sent"
                                HeaderText="Content Sent" UniqueName="Videocontentsent" ItemStyle-Width="100px">
                                <ItemTemplate>
                                    <%# Eval("Video_content_sent")%>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="Content_Viewed" SortExpression="Content_Viewed"
                                HeaderText="Content Viewed" UniqueName="ContentViewed" ItemStyle-Width="100px">
                                <%--  <FilterTemplate>
                                    <div class="Drop-down-child">
                                        <uc1:SessionFilter ID="SessionFilter1" runat="server" />
                                    </div>
                                </FilterTemplate>--%>
                                <ItemTemplate>
                                    <%# Eval("Content_Viewed")%>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="Content_Viewed_Date" SortExpression="Content_Viewed_Date"
                                HeaderText="Viewing Date" UniqueName="ContentViewedDate" ItemStyle-Width="100px">
                                <ItemTemplate>
                                    <%# Eval("Content_Viewed_Date")%>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="Duration_Viewed" SortExpression="Duration_Viewed"
                                HeaderText="Viewing Duration" UniqueName="DurationViewed" ItemStyle-Width="100px">
                                <ItemTemplate>
                                    <%# Eval("Duration_Viewed")%>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                            <telerik:GridTemplateColumn DataField="iplocation" SortExpression="iplocation" HeaderText="Location"
                                UniqueName="iplocation" ItemStyle-Width="100px">
                                <ItemTemplate>
                                    <%# Eval("iplocation")%>
                                </ItemTemplate>
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </MasterTableView>
                    <FilterMenu EnableImageSprites="False" />
                </telerik:RadGrid>

  4. Eyup
    Admin
    Eyup avatar
    3756 posts

    Posted 05 Feb 2014 Link to this post

    Hi Bharat,

    In the javascript functions you are using GridView1 as the ID of the control, but actually the ID of your grid is
    RadGrid1. Can you please verify if this is expected?

    Regards,
    Eyup
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  5. JeffSM
    JeffSM avatar
    40 posts
    Member since:
    May 2014

    Posted 14 Jun 2018 in reply to Eyup Link to this post

    Dear,

    I'm using the correct ID

            var tableView = $find("<%= RadGridX2.ClientID %>").get_masterTableView();
                tableView.set_dataSource(result);

     

    but returns null!

     

     

    what to do?

     

     

     

     

  6. Eyup
    Admin
    Eyup avatar
    3756 posts

    Posted 18 Jun 2018 Link to this post

    Hi Bharat,

    To resolve this issue with client-side binding, you need to add the OnCommand event handler:
    <ClientSettings>
      <ClientEvents OnCommand="function(){}" />
    </ClientSettings>

    As demonstrated in this article:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-binding/understanding-data-binding/client-side-binding/client-side-binding-specifics

    And explained in this one:
    https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/data-binding/understanding-data-binding/client-side-binding/client-side-binding-specifics

    I hope this will prove helpful.

    Regards,
    Eyup
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top