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

Radgrid Filters not working on User Control??

1 Answer 94 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Coen
Top achievements
Rank 1
Coen asked on 16 May 2017, 11:33 AM
Hi 
I have a RadTabStrip with 3 tabs which has a User Control on each tab. Each User Control has a Radgrid on it, I am trying to add filtering to some of the columns. The filters are showing but has no response when entering anything in them, they just don't do anything at all..
Please advise me on this, here is my markup:

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="RadGridsUserControlCS.ascx.cs" Inherits="RadGridsUserControlCS1" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>

<div>

    <asp:Label ID="lblEmpID" runat="server"></asp:Label>

    <br />
    <br />

    <asp:Label ID="Label1" runat="server" Text="Project:"></asp:Label>

    <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource4" DataTextField="projno" DataValueField="dbcsuffix">
    </asp:DropDownList>

    <asp:SqlDataSource ID="SqlDataSource4" runat="server" ConnectionString="<%$ ConnectionStrings:DMCONFIGConnectionString %>" SelectCommand="SELECT projno, dbcsuffix FROM fProject"></asp:SqlDataSource>

    <br />

    <telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="gridFilesDisplay" >
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="gridFilesDisplay" LoadingPanelID="RadAjaxLoadingPanel1" />                
                </UpdatedControls>          
            </telerik:AjaxSetting>      
        </AjaxSettings>
    </telerik:RadAjaxManagerProxy>

    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Vista" ></telerik:RadAjaxLoadingPanel>

    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">

        <script type="text/javascript">

            function onRequestStart(sender, args)
            {
                if (args.get_eventTarget().indexOf("ExportToExcelButton") >= 0 || args.get_eventTarget().indexOf("ExportToPdfButton") >= 0)
                {
                    args.set_enableAjax(false);
                }
            }

        </script>    

         <script type="text/javascript">

             function openDocumentComments(position, Documentno)
             {
                 var oWnd = radopen("DocumentComments.aspx?position=" + position, + "&Documentno=" + Documentno, "DocumentComments");
                 oWnd.center();
             }

             function RefreshPageForGrid()
             {
                 window.location.href = "RadGridsUserControlCS.aspx";
             }

         </script> 

        <script  type="text/javascript">

                    Sys.Application.add_load(AppLoad);

                    function AppLoad() {
                        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
                        Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
                    }

                    function BeginRequest(sender, args) {
                        // Clear the error if it's visible from a previous request.
                        if ($get('Error').style.visibility == "visible")
                            CloseError();
                    }

                    function EndRequest(sender, args) {
                        // Check to see if there's an error on this request.
                        if (args.get_error() != undefined) {
                            // If there is, show the custom error.
                            $get('Error').style.visibility = "visible";

                            // Let the framework know that the error is handled, 
                            //  so it doesn't throw the JavaScript alert.
                            args.set_errorHandled(true);
                        }
                    }

                    function CloseError() {
                        // Hide the error div.
                        $get('Error').style.visibility = "hidden";
                    }
        </script>

    </telerik:RadCodeBlock>

    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Vista">

        <Windows>

            <telerik:RadWindow Skin="Vista" ID="DocumentComments" runat="server" Title="Document Comments"
                Height="400px" Width="300px" Left="150px" ReloadOnShow="true" Modal="true" 
                OpenerElementID="btnProjReject" NavigateUrl="~/DocumentComments.aspx"/>

        </Windows>

    </telerik:RadWindowManager>

    <br />

</div>

<div>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            

            <telerik:RadGrid ID="gridFilesDisplay" 
                Skin="WebBlue" 
                runat="server" 
                AutoGenerateColumns="False" 
                OnNeedDataSource="gridFilesDisplay_NeedDataSource" 
                OnItemCommand="gridFilesDisplay_ItemCommand" 
                OnPreRender="gridFilesDisplay_PreRender" 
                OnLoad="gridFilesDisplay_Load"
                OnItemDataBound="gridFilesDisplay_ItemDataBound" 
                AllowFilteringByColumn="True">

                    <ClientSettings EnablePostBackOnRowClick="true">
                        <Selecting AllowRowSelect="True" />
                    </ClientSettings>

                    <MasterTableView DataKeyNames="position" CommandItemDisplay="Top">

                        <DetailTables>

                            <telerik:GridTableView DataKeyNames="position,category" DataSourceID="SqlDataSource2" Width="100%" runat="server" Name="Categories">

                                <DetailTables>
                                    <telerik:GridTableView runat="server" DataKeyNames="position,category" DataSourceID="SqlDataSource3" Name="Documents" Width="100%">

                                        <ParentTableRelation>
                                            <telerik:GridRelationFields DetailKeyField="category" MasterKeyField="category" />
                                        </ParentTableRelation>

                                        <Columns>

                                            <telerik:GridTemplateColumn DataType="System.Char"  UniqueName="DocumentComments" DataField="DocumentComments" AllowFiltering="false" FilterControlAltText="test"><%--HeaderText="Appr/Reject"--%>

                                               <ItemTemplate>

                                                   <a href="#"  style="text-decoration:none; color: red" onclick="openDocumentComments('<%# DataBinder.Eval(Container.DataItem, "position") %>, <%# DataBinder.Eval(Container.DataItem, "Documentno") %>'); return false;">Reviewed</a> 
                                               
                                               </ItemTemplate>
                           
                                                <EditItemTemplate>

                                                    <%--<asp:Button runat="server" ID="btnDocApprove" Text="Approve" Width="60px" OnClick="btnDocApprove_Click" />--%>

                                                    <%--<a href="#" onclick="openDocRadWindow('<%# DataBinder.Eval(Container.DataItem, "WBSEmpDocId") %>', '<%# DataBinder.Eval(Container.DataItem, "LineNbr") %>'); return false;" style="color: red">Reject</a>--%>

                                                </EditItemTemplate>

                                                <HeaderStyle Width="12%" Font-Bold="True" />
                                                <ItemStyle Font-Bold="true" HorizontalAlign="Center"/>

                                            </telerik:GridTemplateColumn>


                                            <telerik:GridBoundColumn DataField="position" HeaderText="Position" UniqueName="position" Visible="false" AllowFiltering="false">
                                                
                                            </telerik:GridBoundColumn>

                                            <telerik:GridBoundColumn DataField="category" HeaderText="Category" UniqueName="category" Visible="false" AllowFiltering="false">
                                                
                                                <HeaderStyle Font-Bold="true" />
                                            </telerik:GridBoundColumn>

                                            <telerik:GridBoundColumn DataField="Documentno" HeaderText="Document No" UniqueName="Documentno" AllowFiltering="true">
                                                
                                                <HeaderStyle Font-Bold="true" Width="10%" />
                                            </telerik:GridBoundColumn>

                                            <telerik:GridBoundColumn DataField="Rev_Now" HeaderText="Rev Now" UniqueName="Rev_Now" AllowFiltering="false">
                                                
                                                <HeaderStyle Font-Bold="true" Width="10%" />
                                            </telerik:GridBoundColumn>

                                            <telerik:GridBoundColumn DataField="STS_Now" HeaderText="STS Now" UniqueName="STS_Now" AllowFiltering="false">
                                                
                                                <HeaderStyle Font-Bold="true" Width="10%" />
                                            </telerik:GridBoundColumn>

                                            <telerik:GridBoundColumn DataField="MDR_Title" HeaderText="MDR Title" UniqueName="MDR_Title" AllowFiltering="true" FilterControlWidth="100px" >
                                                
                                                <HeaderStyle Font-Bold="true" Width="35%" />
                                            </telerik:GridBoundColumn>

                                            <telerik:GridBoundColumn DataField="storename" HeaderText="storename" UniqueName="storename" Visible="false" AllowFiltering="false">
                                                
                                                <HeaderStyle Font-Bold="true" />
                                            </telerik:GridBoundColumn>

                                            <telerik:GridTemplateColumn HeaderText="Download Document" AllowFiltering="false">

                                                <ItemTemplate>
                                                    <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("storename") %>' CommandName="DownloadMyFile" Text="Download"></asp:LinkButton>
                                                    <%--<telerik:RadButton RenderMode="Lightweight" ID="DownloadMyFile" OnClientClicked="DownloadMyFile" CommandName="DownloadMyFile" Text="Download" AutoPostBack="false" runat="server" Width="90px">
                                                    </telerik:RadButton>--%>
                                                    <%--Text='<%# Eval("storename") %>'--%>
                                                </ItemTemplate>

                                                <HeaderStyle Font-Bold="true" />
                                            </telerik:GridTemplateColumn>

                                        </Columns>

                                    </telerik:GridTableView>
                                </DetailTables>

                                <ParentTableRelation>

                                    <telerik:GridRelationFields DetailKeyField="position" MasterKeyField="position"></telerik:GridRelationFields>

                                </ParentTableRelation>

                                <Columns>

                                    <telerik:GridBoundColumn HeaderText="Position" DataField="position" UniqueName="position" Visible="false" AllowFiltering="false">
                                        
                                    </telerik:GridBoundColumn>

                                    <telerik:GridBoundColumn HeaderText="Category" DataField="category" UniqueName="category" AllowFiltering="false">
     
                                        <HeaderStyle Width="10%" Font-Bold="true" />

                                    </telerik:GridBoundColumn>

                                    <telerik:GridBoundColumn HeaderText="Category Description" DataField="categorydesc" UniqueName="categorydesc" AllowFiltering="false">

                                        <HeaderStyle Width="90%" Font-Bold="true" />

                                    </telerik:GridBoundColumn>

                                </Columns>

                            </telerik:GridTableView>

                        </DetailTables>

                        <Columns>

                            <telerik:GridBoundColumn HeaderText="Position" DataField="position" UniqueName="position" Visible="false" AllowFiltering="false">
                                
                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn HeaderText="First Name" DataField="firstname" UniqueName="firstname" AllowFiltering="false">

                                <HeaderStyle Width="20%" Font-Bold="true" />

                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn HeaderText="Last Name" DataField="lastname" UniqueName="lastname" AllowFiltering="false">

                                <HeaderStyle Width="80%" Font-Bold="true" />

                            </telerik:GridBoundColumn>

                        </Columns>
                    </MasterTableView>

            </telerik:RadGrid>

            <asp:Button ID="btnApprove" runat="server" Text="Approve" Visible="false" OnClick="btnApprove_Click" />

        </ContentTemplate>
    </asp:UpdatePanel>
</div>

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DocViewConnectionString %>"
    DeleteCommand=""
    InsertCommand=""
    SelectCommand="xLevel1Names" SelectCommandType="StoredProcedure"
    UpdateCommand="" UpdateCommandType="Text" >
       
    <SelectParameters>

        <asp:SessionParameter Name="User" SessionField="User" Type="String" />
      <%--  <asp:SessionParameter Name="User" SessionField="User" Type="String" />--%>

    </SelectParameters>

</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DocViewConnectionString %>"
    DeleteCommand=""
    InsertCommand=""
    SelectCommand="xLevel2Categories" SelectCommandType="StoredProcedure"
    UpdateCommand="" UpdateCommandType="Text" >
       
    <SelectParameters>

        <asp:SessionParameter Name="User" SessionField="User" Type="String" />

    </SelectParameters>

</asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:DocViewConnectionString %>"
    DeleteCommand=""
    InsertCommand=""
    SelectCommand="xLevel3Docs" SelectCommandType="StoredProcedure"
    UpdateCommand="" UpdateCommandType="Text" >
       
    <SelectParameters>

        <asp:SessionParameter Name="User" SessionField="User" Type="String" />

        <asp:Parameter Name="category" Type="String" />

    </SelectParameters>

</asp:SqlDataSource>

<br />

<asp:Label ID="lblMessage" runat="server"></asp:Label>

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 17 May 2017, 10:26 AM

Hello,

I have just answered your support ticket with the same question, and I am pasting my response here for anyone else with a similar problem.

I can see two issues with the provided code:

  • There is a RadAjaxManagerProxy that ajax-enables the grid, so you should remove UpdatePanel1, because it only results in nested update panels.
  • The grid uses a declarative data source (two SqlDataSource instances), and also has a NeedDataSource event handler. You should choose only one of those approaches to supply the grid with data.

I am also attaching here a locally runnable version of the demo with filtering enabled so you can compare with your actual code and find the difference that causes the problem.

If this does not help, please isolate this issue in a small runnable example so I can inspect it. Actual application logic and data are not needed, a hardcoded datatable or a list will suffice, or using a standard database like Northwind.

On a side note, you may want to enable paging if the data source will return a significant amount of data. Also, you may want to enable the RenderSelectedPageOnly property of the multipage if each tab click will perform a postback anyway.

Regards,

Marin Bratanov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Coen
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or