Below is the code snippet used in a radgrid usercontrol
Protected Sub FilterCombo_SelectedIndexChanged(ByVal o As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)
Dim filterItem As GridFilteringItem = CType(CType(o, RadComboBox).NamingContainer, GridFilteringItem)
If e.Value = "NoFilter" Then
filterItem.FireCommandEvent("Filter", New Pair("NoFilter", Me.colname))
Else
filterItem.FireCommandEvent("Filter", New Pair("EqualTo", Me.colname))
End If
End Sub
Protected Sub RadGridList_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGridList.ItemCommand
If
(e.CommandName = RadGrid.FilterCommandName) Then
If (TypeOf e.CommandArgument Is Pair) Then
Dim objpair As Pair = DirectCast(e.CommandArgument, Pair)
RadGridList.MasterTableView.FilterExpression = "([" & objpair.First.ToString & "] = '" & objpair.Second.ToString & "') "
RadGridList.MasterTableView.Rebind()
End If
Private Sub RadGridList_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGridList.PreRender
Dim filterExpr As String
RadGridList.Skin = skinType
filterExpr =
"([" & FilterExpression.ToUpper & "] = '" & FilterValue.ToUpper & "') "
If (Not String.IsNullOrEmpty(filterVal) And (Not Page.IsPostBack)) Then
RadGridList.MasterTableView.FilterExpression = filterExpr
RadGridList.MasterTableView.Rebind()
filterExpr =
""
Else
If Not String.IsNullOrEmpty(RadGridList.MasterTableView.FilterExpression.ToString) Then
RadGridList.MasterTableView.FilterExpression = RadGridList.MasterTableView.FilterExpression
End If
RadGridList.MasterTableView.Rebind()
End If
We are dynamically creating all columns and filters in code behind in a common radgrid usercontrol. The RadComboBox is in a inner private Class implementing ITemplate for Filter Template. The columns and the filter applied are driven through configuration e.g. through configuration we can decide to use Combo Filter for Column X and not for Column Y but can change this in future.
We are firing event in radcombox selectedindexchange which we able to capture in the itemCommand function in the user control but when rebind the grid with the filter expression the results are not filtered.
Additionally we would like to know,
a) if pair generated in the selectedindexchange method to fire command event should column name and column value or Condition e.g. "EqualTo" and column name should be stored in the Pair object, because in debugging the typical filterexpression we saw was with condition name and column name.
b) And how to ensure all other column filter are preserved in the filter expression in this scenario where we are seeing some Pair are with Filter Condition & Column Name and some are with Column Name & Column Value
c) multiple filter expresson is also not retaining the values and filter the results when we have multiple type of filters across the column e.g. one is based on date, one is based on radcombo, others are based text entered in textbox
Need your help to resolve this at the earliest