FilterTemplate Javascript event runtime error

5 posts, 0 answers
  1. Venkatesh
    Venkatesh avatar
    21 posts
    Member since:
    Jul 2014

    Posted 27 Jun 2015 Link to this post

    Hi,

     

    I have a RadComboBox inside the FilterTemplate with OnClientSelectedIndexChanged="NameFilterIndexChanged". I am making radgrid's AllowFilteringByColumn="Flase" when no data is available and AllowFilteringByColumn="true" when data is available.

     

     I am getting error like "0*800a1391 - JavaScript runtime error: 'NameFilterIndexChanged' is undefined" when AllowFilteringByColumn="true". Please help me on this.

     

    Regards,

    Venkatesh.

  2. Nencho
    Admin
    Nencho avatar
    1458 posts

    Posted 01 Jul 2015 Link to this post

    Hello Venkatesh,

    I would suggest you to place the function for the OnClientSelectedIndexChanged in the FilterTemplate, where the RadComboBox in question is nested in. You can observe this approach, implemented in the following online demo (refer to RadComboBoxCity):

    http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

    Regards,
    Nencho
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Venkatesh
    Venkatesh avatar
    21 posts
    Member since:
    Jul 2014

    Posted 02 Jul 2015 Link to this post

    Hi Nencho,Thanks for your reply. I am also doing the same. Please find my sample code below. aspx:<telerik:GridTemplateColumn
    HeaderText="Name" HeaderStyle-BackColor="#64B7EA" UniqueName="Name"
    DataField="Name" HeaderStyle-Width="100px" FilterControlWidth="90%">
                                                <ItemTemplate>
                                                   
    <asp:Label ID="uxNameLabel" runat="server" Text='<%# Eval("Name")
    %>' />
                                                </ItemTemplate>
                                                <FilterTemplate>
                                                   
    <telerik:RadComboBox ID="uxNameFilterRCB" EnableItemCaching="True"
    AppendDataBoundItems="true" Width="100%"
                                                        runat="server" OnClientSelectedIndexChanged="NameFilterIndexChanged">
                                                    </telerik:RadComboBox>
                                                    <telerik:RadScriptBlock ID="NameScriptBolck" runat="server">
                                                        <script type="text/javascript">
                                                            function NameFilterIndexChanged(sender, args) {
                                                               
    document.getElementById("<%# uxSelectedName.ClientID%>").value =
    args.get_item().get_value();
                                                               
    var tableView = $find("<%# Container.OwnerTableView.ClientID
    %>");
                                                                if(args.get_item().get_value() === '0')
                                                                {
                                                                    tableView.filter("Name", "", "NoFilter");
                                                                }
                                                                else
                                                                {
                                                                   
    tableView.filter("Name", args.get_item().get_value(), "EqualTo");
                                                                }
                                                            }
                                                        </script>
                                                    </telerik:RadScriptBlock>
                                                </FilterTemplate>
                                                <EditItemTemplate>
                                                   
    <asp:DropDownList runat="server" ID="uxNameEditComboBox"
    DropDownAutoWidth="Enabled" Width="100%" />
                                                </EditItemTemplate>
                                            </telerik:GridTemplateColumn> And i have a hiddenfield.<asp:HiddenField ID="uxSelectedName" runat="server" Value="All" /> aspx.csIn Itemdatabound:if (e.Item is GridFilteringItem)
                {
                    var editItem = (GridFilteringItem)e.Item;RadComboBox uxNameFilterRCB= (RadComboBox)editItem.FindControl("uxNameFilterRCB");
                  ---  here i'll fill the data into the dropdown. And selecting dropdown value using hiddenfield. ---
    } But no use. I am getting error. Regards,Venkatesh.
  5. Venkatesh
    Venkatesh avatar
    21 posts
    Member since:
    Jul 2014

    Posted 02 Jul 2015 in reply to Nencho Link to this post

    Hi Nencho,

    Thanks for your reply. I am also doing the same. Please find my sample code below. 

    aspx:

    <telerik:GridTemplateColumn
    HeaderText="Name" HeaderStyle-BackColor="#64B7EA" UniqueName="Name"
    DataField="Name" HeaderStyle-Width="100px" FilterControlWidth="90%">
                                                <ItemTemplate>

    <asp:Label ID="uxNameLabel" runat="server" Text='<%# Eval("Name")
    %>' />
                                                </ItemTemplate>
                                                <FilterTemplate>

    <telerik:RadComboBox ID="uxNameFilterRCB" EnableItemCaching="True"
    AppendDataBoundItems="true" Width="100%"
                                                        runat="server" OnClientSelectedIndexChanged="NameFilterIndexChanged">
                                                    </telerik:RadComboBox>
                                                    <telerik:RadScriptBlock ID="NameScriptBolck" runat="server">
                                                        <script type="text/javascript">
                                                            function NameFilterIndexChanged(sender, args) {

    document.getElementById("<%# uxSelectedName.ClientID%>").value =
    args.get_item().get_value();

    var tableView = $find("<%# Container.OwnerTableView.ClientID
    %>");
                                                                if(args.get_item().get_value() === '0')
                                                                {
                                                                    tableView.filter("Name", "", "NoFilter");
                                                                }
                                                                else
                                                                {

    tableView.filter("Name", args.get_item().get_value(), "EqualTo");
                                                                }
                                                            }
                                                        </script>
                                                    </telerik:RadScriptBlock>
                                                </FilterTemplate>
                                                <EditItemTemplate>

    <asp:DropDownList runat="server" ID="uxNameEditComboBox"
    DropDownAutoWidth="Enabled" Width="100%" />
                                                </EditItemTemplate>
                                            </telerik:GridTemplateColumn> 

    And i have a hiddenfield

    <asp:HiddenField ID="uxSelectedName" runat="server" Value="All" /> 

    aspx.cs

    In Itemdatabound:

    if (e.Item is GridFilteringItem)
                {
                    var editItem = (GridFilteringItem)e.Item;RadComboBox uxNameFilterRCB= (RadComboBox)editItem.FindControl("uxNameFilterRCB");
                  ---  here i'll fill the data into the dropdown. And selecting dropdown value using hiddenfield. ---

    But no use. I am getting error. 

    Regards,Venkatesh.

  6. Eyup
    Admin
    Eyup avatar
    3015 posts

    Posted 07 Jul 2015 Link to this post

    Hi Venkatesh,

    I am sending a sample RadGrid web site containing various solutions for integrating grid filtering via a RadComboBox. Please run the attached application and let me know if it helps you.

    Regards,
    Eyup
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017