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

CurrentFilterFunction with AutoPostBackOnFilter - Filter lost

1 Answer 323 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Veronique
Top achievements
Rank 1
Veronique asked on 14 May 2012, 03:30 PM
            I need to hide the filter icon, enable the AutoPostBackOnFilter and set the default filter function value.
The default filter function may be different for each column depending on what the client wants.

I have a problem. 
When the application loads, the filters are exactly what I specified in the CurrentFilterFunction property.
When I filter the first column, the filters reset to something else.

<telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1" DataSourceID="SqlDataSource1" AllowFilteringByColumn="True" PageSize="15" AllowPaging="True" runat="server" >           
    <MasterTableView >
       
<Columns>
           
<telerik:GridNumericColumn DataField="OrderID" HeaderText="OrderID" AutoPostBackOnFilter="true" CurrentFilterFunction="LessThanOrEqualTo" />
            <telerik:GridBoundColumn  DataField="ShipName" HeaderText="ShipName" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" />
            <telerik:GridDateTimeColumn  DataField="OrderDate" HeaderText="OrderDate" AutoPostBackOnFilter="true" CurrentFilterFunction="LessThanOrEqualTo" />                   
        </Columns>                                             
   
</MasterTableView>           
</telerik:RadGrid>


<asp:SqlDataSource ID="SqlDataSource1" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    ProviderName="System.Data.SqlClient" SelectCommand="SELECT * FROM Orders" runat="server">
</asp:SqlDataSource>


In this example, when I filter the shipName with the letter 'a', it is filtered correctly with the "Contains" filter expression.
Then I filter the OrderId with the value 10300. 
I expect the filter function to be "LessThanOrEqualTo" as I specified, but instead, it is set to "EqualTo". 
Is it a bug ?
Is there a workaround ?

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 15 May 2012, 07:43 AM
Hi Veronique,

The default behavior for the grid is not to persist the CurrentFilterFunction on postback for columns that do not have value entered in the filter. You can try manually saving this setting. One approach is to set the CurrentFilterFunction property in the Page_PreRender event for the page. Here is the sample code.
C#:
protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);
    RadGrid1.Columns[0].CurrentFilterFunction = GridKnownFunction.LessThanOrEqualTo;
    RadGrid1.Rebind();
}

Thanks,
Shinu.
Tags
Grid
Asked by
Veronique
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or