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

[Solved] Strange Filter Template behavior

1 Answer 87 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reuven
Top achievements
Rank 1
Reuven asked on 09 Jul 2009, 01:45 AM
I have a grid bound to an objectdatasource (base class datatable) and am trying to fliter using a dropdownlist for a boolean variable (took forever to figure our that the filter required a capitalized "True").

Here is my filter template:
                <FilterTemplate> 
                    Show:  
                    <asp:DropDownList runat="server" ID="ddlFilter" OnSelectedIndexChanged="FilterCombo_SelectedIndexChanged" 
                        AutoPostBack="true">  
                        <asp:ListItem Value="None" Text="All Cases" /> 
                        <asp:ListItem Value="Pediatric" Text="Pediatric only" /> 
                    </asp:DropDownList> 
                </FilterTemplate> 
 

the selectedIndexChanged:
        Protected Sub FilterCombo_SelectedIndexChanged(ByVal sender As ObjectByVal e As System.EventArgs)  
            Dim filterExpression As String 
            If CType(sender, DropDownList).SelectedValue = "Pediatric" Then 
                filterExpression = "([Pediatric] = True)" 
            Else 
                filterExpression = String.Empty  
            End If 
            RadGridCases.MasterTableView.FilterExpression = filterExpression  
            RadGridCases.MasterTableView.Rebind()  
        End Sub 
 
itemcreated (it is the only filter I use):
        Protected Sub RadGridCases_ItemCreated(ByVal sender As ObjectByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGridCases.ItemCreated  
            If TypeOf (e.Item) Is Telerik.Web.UI.GridFilteringItem Then 
                If Not RadGridCases.MasterTableView.FilterExpression Is String.Empty Then 
                    CType(e.Item.FindControl("ddlFilter"), DropDownList).SelectedValue = "Pediatric" 
                End If 
            End If 
        End Sub 

I check on NeedDataSource and the filteringexpression is correct ([Pediatric] = True), but it wasn't filtering.

So I created a test checkbox column:
            <telerik:GridCheckBoxColumn DataField="Pediatric" AllowFiltering="true" /> 
 
and while this set the exact same filteringexpression, it worked. Combining my template and setting the GridCheckBoxColumn visible property to false also works, so no idea what is going on. Also, the sorting does work if any of this filtering is occuring (even if off)

Thanks,
Reuven

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 13 Jul 2009, 11:01 AM
Hi Reuven,

I also checked your sample code in a project and it is working OK, just as expected. Can you post  some more sample code and RadGrid's markup so that we can see what goes behind the scenes.

All the best,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Grid
Asked by
Reuven
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or