Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 84751

Custom filter on one column that takes date values from itself and from another column to do a between like filter

$
0
0

What i want is to add a custom filter to one column that will takes the date from this column as first date and a date in another column as the second date to do a between like filter with these two dates.

I added a custom filter with  FilterListOptions="VaryByDataTypeAllowCustom".

then i added an handler like this (my second date is in "Col2") but this isn't working. What am i missing?:

Protected Sub gvAbsence_ItemCommand(source As Object, e As GridCommandEventArgs) Handles gvAbsence.ItemCommand
        If e.CommandName = RadGrid.FilterCommandName Then
            Dim filterPair As Pair = DirectCast(e.CommandArgument, Pair)
            If filterPair.First.ToString() = "Custom" Then
                Dim colName As String = filterPair.Second.ToString()
                If colName = "Col0" Then
                    Dim tbPattern As TextBox = TryCast(TryCast(e.Item, GridFilteringItem)(colName).Controls(0), TextBox)
                    Dim values As String() = tbPattern.Text.Split(" "c)
                    If values.Length = 1 Then
                        e.Canceled = True
                        Dim newFilter As String = "(([" + filterPair.Second + "] <='" + values(0) + "') AND ([" + "Col2" + "] >='" + values(0) + "'))"
                        If gvAbsence.MasterTableView.FilterExpression = "" Then
                            gvAbsence.MasterTableView.FilterExpression = newFilter
                        Else
                            gvAbsence.MasterTableView.FilterExpression = (Convert.ToString("((" + gvAbsence.MasterTableView.FilterExpression + ") AND (") & newFilter) + "))"
                        End If
                        gvAbsence.Rebind()
                    End If
                End If
            End If
        End If
    End Sub


Viewing all articles
Browse latest Browse all 84751

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>