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

GridTemplateColumn with FilterTemplate when AllowFiltering=true causes an error.

1 Answer 329 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Greg S
Top achievements
Rank 1
Greg S asked on 30 Jul 2016, 07:20 PM

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" />

1 Answer, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 03 Aug 2016, 02:21 PM
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.
Tags
Grid
Asked by
Greg S
Top achievements
Rank 1
Answers by
Maria Ilieva
Telerik team
Share this question
or