Hi guys,
I'm doing custom filtering and need to know what item the user has selected as the filtering option (StartsWith, EndsWith, Contains, etc.)
I can get a reference to the value in the filter textbox like this:
    
How do I get a reference to the adjacent Combobox and its selected item?
Thanks,
Ken
                                I'm doing custom filtering and need to know what item the user has selected as the filtering option (StartsWith, EndsWith, Contains, etc.)
I can get a reference to the value in the filter textbox like this:
| fbox = CType((CType(e.Item, GridFilteringItem))("Description").Controls(0), TextBox) | 
How do I get a reference to the adjacent Combobox and its selected item?
Thanks,
Ken
10 Answers, 1 is accepted
0
                                
                                                    Princy
                                                    
                                            
    Top achievements
    
            
                
                Rank 2
            
    
                                                
                                                answered on 04 Mar 2010, 06:56 AM
                                            
                                        0
                                
                                                    kencox
                                                    
                                            
    Top achievements
    
            
                
                Rank 1
            
    
                                                
                                                answered on 04 Mar 2010, 10:03 PM
                                            
                                        Thanks Princy, but I'm still not getting it.
Are you referring to RadGrid1.MasterTableView.FilterExpression? If so, the string is empty in the FilterCommand event.
Ken
                                        Are you referring to RadGrid1.MasterTableView.FilterExpression? If so, the string is empty in the FilterCommand event.
Ken
0
                                Hello Ken,
You can get the filter information on ItemCommand as shown in the example below:
 
The above code-snippet is taken from the following topic:
Operating with the FilterExpression of Telerik RadGrid manually
I hope this helps.
Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
                                        You can get the filter information on ItemCommand as shown in the example below:
Private gridMessage1 As  String = Nothing, gridMessage2 As String  = Nothing;Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.ItemCommand  If e.CommandName = RadGrid.FilterCommandName Then    Dim filterPair As Pair = DirectCast(e.CommandArgument, Pair)    gridMessage1 = "Current Filter function: '" + filterPair.First + "' for column '" + filterPair.Second + "'"    Dim filterBox As TextBox = CType((CType(e.Item, GridFilteringItem))(filterPair.Second.ToString()).Controls(0), TextBox)    gridMessage2 = "<br> Entered pattern for search: " + filterBox.Text  End IfEnd SubThe above code-snippet is taken from the following topic:
Operating with the FilterExpression of Telerik RadGrid manually
I hope this helps.
Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
                                
                                                    kencox
                                                    
                                            
    Top achievements
    
            
                
                Rank 1
            
    
                                                
                                                answered on 04 Mar 2010, 10:33 PM
                                            
                                        Hi Daniel,
That gives me the values for the filter that just fired. I'm doing multi-column filtering so I need to pass the filter parameters from all columns to the stored procedure.
I have a feeling that accessing the columns by name might work:
    
Thanks for your input!
Ken
                                        That gives me the values for the filter that just fired. I'm doing multi-column filtering so I need to pass the filter parameters from all columns to the stored procedure.
I have a feeling that accessing the columns by name might work:
| Dim colDescription As GridColumn | 
| colDescription = RadGrid1.MasterTableView.GetColumnSafe("Description") | 
| Dim DescriptionFilterFunction As String = colDescription.CurrentFilterFunction.ToString | 
| Dim DescriptionFilterValue As String = colDescription.CurrentFilterValue | 
Thanks for your input!
Ken
0
                                
                                                    kencox
                                                    
                                            
    Top achievements
    
            
                
                Rank 1
            
    
                                                
                                                answered on 04 Mar 2010, 11:48 PM
                                            
                                        Still no luck. I need to get the filter function and the search pattern for all columns, not just the one that triggered the itemcommand.
                                        0
                                Hello Ken,
You can traverse all columns and extract the current filter value/function manually:
Regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
                                        You can traverse all columns and extract the current filter value/function manually:
Protected Sub Button1_Click(sender As Object, e As EventArgs)    For Each column As GridColumn In RadGrid1.MasterTableView.RenderColumns        If TypeOf column Is GridEditableColumn Then            Dim col As GridEditableColumn = TryCast(column, GridEditableColumn)            Dim cff As String = col.CurrentFilterFunction.ToString()            Dim cfv As String = col.CurrentFilterValue.ToString()            '....        End If    NextEnd SubRegards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
                                
                                                    kencox
                                                    
                                            
    Top achievements
    
            
                
                Rank 1
            
    
                                                
                                                answered on 17 Mar 2010, 08:06 PM
                                            
                                        Hi Daniel,
I'm still unable to get the correct value out of the CurrentFilterFunction. This line...
| Dim cff As String = col.CurrentFilterFunction.ToString() | 
always returns "NoFilter".
How do I get the Contains, StartsWith or EndsWith to work?
Thanks,
Ken
0
                                Hello Ken,
It seems that I missed the fact that you use custom filtering. The problem is that when you cancel the built-in filtering, the current filter function won't be populated and thus you can't access it. I noticed you submitted a support ticket, where Martin suggested that you use the filter pair in order to access the current filter function name. This approach is feasible if you want to access the current filter function for a single column. When this is not the case, you can manually set the current filter function according to the value, coming on the filter command. Please try the following:
 
Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
                                        It seems that I missed the fact that you use custom filtering. The problem is that when you cancel the built-in filtering, the current filter function won't be populated and thus you can't access it. I noticed you submitted a support ticket, where Martin suggested that you use the filter pair in order to access the current filter function name. This approach is feasible if you want to access the current filter function for a single column. When this is not the case, you can manually set the current filter function according to the value, coming on the filter command. Please try the following:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click    For Each column As GridColumn In RadGrid1.MasterTableView.RenderColumns        If TypeOf column Is GridEditableColumn Then            Dim col As GridEditableColumn = TryCast(column, GridEditableColumn)            Dim cff As String = col.CurrentFilterFunction.ToString()            Dim cfv As String = col.CurrentFilterValue.ToString()            lblFilterInfo.Text = lblFilterInfo.Text & cff & ":" & cfv & "<br>"        End If    NextEnd Sub    Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand        If e.CommandName = RadGrid.FilterCommandName Then            e.Canceled = True            Dim filterPair As Pair = CType(e.CommandArgument, Pair)            Dim filterFunction As GridKnownFunction = DirectCast([Enum].Parse(GetType(GridKnownFunction), filterPair.First), GridKnownFunction)            RadGrid1.MasterTableView.GetColumn(filterPair.Second).CurrentFilterFunction = filterFunction        End If    End SubBest regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
                                
                                                    kencox
                                                    
                                            
    Top achievements
    
            
                
                Rank 1
            
    
                                                
                                                answered on 28 Mar 2010, 10:37 PM
                                            
                                        Hi Daniel,
Thanks for the answer. I think this is getting me close to what I need.
However, your example demonstrates fetching the filter function and filter value on a button click event.
Is it possible to get the function and value whenever a filter control does an autopostback? (That is, the user types the value on which to filter and selects from the dropdownlist.)
I'd like the custom filtering to behave for the user the same as the built-in filtering.
Thanks,
Ken
                                        Thanks for the answer. I think this is getting me close to what I need.
However, your example demonstrates fetching the filter function and filter value on a button click event.
Is it possible to get the function and value whenever a filter control does an autopostback? (That is, the user types the value on which to filter and selects from the dropdownlist.)
I'd like the custom filtering to behave for the user the same as the built-in filtering.
Thanks,
Ken
0
                                Hello Ken,
I created a sample project for you. It uses the same approach to get the current filter parameters on Page_PreRender.
I hope this helps.
Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
                                        I created a sample project for you. It uses the same approach to get the current filter parameters on Page_PreRender.
I hope this helps.
Best regards,
Daniel
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.