GridTemplateColumn with FilterTemplate when AllowFiltering=true causes an error.

2 posts, 0 answers
  1. Greg S
    Greg S avatar
    8 posts
    Member since:
    Jul 2015

    Posted 30 Jul Link to this post

    After a few hours of searching the internet on the error "Specified argument was out of the range of valid values", I discovered that the cause was the GridTemplateColumn behaving differently that a GridBoundColumn with regards to filtering. In the code snippet below, you can use the one filter just fine. If you change the telerik:GridTemplateColumn (column 2) to AllowFiltering='true' while having a <FilterTemplate> element, using the filter on column 3 will throw an error. AllowFiltering='true' doesn't cause a problem if there's no <FilterTemplate> element. Note that changing the GridBoundColumn ( column 1) between AllowFiltering= true/false doesn't cause an issue. It's only the GridTemplateColumn type.

    The different behavior between the GridBoundColumn and GridTemplateColumn types seems like a bug.

     

          <telerik:RadGrid runat="server" DataSourceID="sql_tables" AllowFilteringByColumn="true" AutoGenerateColumns="false">
                <MasterTableView>
                    <Columns>
                        <telerik:GridBoundColumn DataField="name" HeaderText="name" AllowFiltering="true" UniqueName="name1">
                            <FilterTemplate>
                                custom filter template on GridBoundColumn is OK
                            </FilterTemplate>
                        </telerik:GridBoundColumn>
     
                        <telerik:GridTemplateColumn DataField="name" HeaderText="name-template" AllowFiltering="false" UniqueName="name2">
                            <ItemTemplate>
                                <%#Eval("name") %>
                            </ItemTemplate>
                            <FilterTemplate>custom filter on GridTemplateColumn breaks filtering.</FilterTemplate>
                            <HeaderStyle BackColor="Pink" />
                        </telerik:GridTemplateColumn>
     
    <telerik:GridBoundColumn DataField="type" HeaderText="type" AllowFiltering="true" UniqueName="type"/>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
     
            <asp:SqlDataSource runat="server" ID="sql_tables" ConnectionString="<%$ ConnectionStrings:MyDB%>" SelectCommand="select top 4 name, object_id, schema_id, type, type_desc from sys.tables" />

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 03 Aug Link to this post

    Hi Greg,

    The same scenario is presented in the online demo below and works properly without an error:
    http://demos.telerik.com/aspnet-ajax/grid/examples/functionality/filtering/filter-templates/defaultcs.aspx

    Test it on your end and verify what the difrenace in your case is.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top