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

DateTime Filter Operators not available

5 Answers 40 Views
GridView
This is a migrated thread and some comments may be shown as answers.
T
Top achievements
Rank 1
T asked on 22 Nov 2011, 08:35 PM
We are loading data dynamically from a System.DataTable with typed columns.  DateTime columns types do not have the common operators like:
Is less than, Is less than or equal to, ... and so on..., that are usually found on numeric style columns types.  Only operators available are: Is equal to and Is not equal to.

String data does contain what we expect: Is equal to, Is not equal to, Starts with. .. and so on...
and the numeric values have the other operators: Is less than,  Is less than or equal to, ... and so on...

The version of the Telerik.Windows.Controls dll is 2011.2.920.35.  Would the Q3 version have these operators?  Or can we use the new Q3 FilterOperatorsLoading event handler to add them?

5 Answers, 1 is accepted

Sort by
0
Accepted
Rossen Hristov
Telerik team
answered on 23 Nov 2011, 11:50 AM
Hello T,

That sounds strange since DateTime's should have the comparison operators. Can you please send us a sample project that demonstrates how a DateTime column does not have these operators. Have in mind that the column should be informed that it displays DateTimes if that is not the case. This is done through its DataType property.

By the way, you can easily check that every DateTime column in our Quick Start examples does indeed show these operators.

As for the string columns, currently we do not support the comparison operators since the string class does not overload the <, <==, >, >== operators. We have some plans for adding such support if interest grows. Here you can vote for this feature.

Greetings,
Ross
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
T
Top achievements
Rank 1
answered on 23 Nov 2011, 05:30 PM
Thanks for the response.  There are just two operators, ''Is equal to'' and ''Is not equal to'' for the DateTime type as seen in the attached image.

This is the XAML for the Rad Grid View:

<telerik:RadGridView Name="gvRawData" ItemsSource="{Binding Path=RawDataListDT}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
         EnableColumnVirtualization="True" EnableRowVirtualization="True" CanUserInsertRows="False" IsReadOnly="True"
         telerik:StyleManager.Theme="Metro" ScrollViewer.HorizontalScrollBarVisibility="Auto" BorderThickness="0"
         ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollMode="RealTime" Margin="2" CanUserSelect="False"
         AutoGenerateColumns="True" RowIndicatorVisibility="Collapsed" FontSize="9pt" BorderBrush="DarkGray"
          CanUserDeleteRows="False" CanUserFreezeColumns="False" CanUserSortColumns="True"
         HeaderRowStyle="{StaticResource headerRow}" ShowGroupPanel="False" >
</telerik:RadGridView>

The data is loaded with MVVM through the Model as a DataTable.  This is the mock code that ultimately generates the DataTable is as follows:

Public Function getRawDataListDT() As DataTable
 
    Dim returnCollection As New DataTable
 
    Dim newDataColumn As New DataColumn("Name")
    newDataColumn.DataType = GetType(String)
    returnCollection.Columns.Add(newDataColumn)
 
    newDataColumn = New DataColumn("FilePath")
    newDataColumn.DataType = GetType(String)
    returnCollection.Columns.Add(newDataColumn)
 
    newDataColumn = New DataColumn("FileSize")
    newDataColumn.DataType = GetType(Long)
    returnCollection.Columns.Add(newDataColumn)
 
    newDataColumn = New DataColumn("LastWriteTime")
    newDataColumn.DataType = GetType(DateTime)
    returnCollection.Columns.Add(newDataColumn)
 
    Dim maxItems As Integer = _showTop
    If maxItems < 1 Then
        maxItems = Integer.MaxValue
    End If
 
    Dim rnd As New Random()
    Dim sizernd As New Random()
 
    While returnCollection.Rows.Count < maxItems
 
        Dim dr As DataRow = returnCollection.NewRow()
 
        Dim path As String = ""
        Dim name As String = ""
 
        Dim nextRnd As Integer = rnd.Next(1, 4)
 
        Select Case nextRnd
            Case 1
                path = "C:\Programs\DatTblSoft\"
                name = "configfile"
                dr("LastWriteTime") = DateTime.Parse("2010-02-28 09:23:45 PM").AddDays(109).AddSeconds(10900)
                Exit Select
            Case 2
                path = "D:\DataTbl\IEScapeFoxerari\"
                name = "filecache"
                dr("LastWriteTime") = DateTime.Now
                Exit Select
            Case 3
                path = "E:\Users\DT\"
                name = "mydocuemnt"
                dr("LastWriteTime") = DateTime.Now.AddDays(45).AddSeconds(789)
                Exit Select
        End Select
 
        dr("Name") = String.Format("{0}_{1}.ext", name, returnCollection.Rows.Count)
        dr("FilePath") = String.Format("{0}{1}", path, dr("Name").ToString())
        dr("FileSize") = sizernd.Next(10, 10000000)
 
        returnCollection.Rows.Add(dr)
    End While
 
    Return returnCollection
End Function
0
T
Top achievements
Rank 1
answered on 23 Nov 2011, 07:11 PM
Update:

Q3 2011 (version: 2011.3.1116.35) solves this.  The 'Less than ...' and 'Greater than ...' operators are now available as well.

Thanks
0
Franciele
Top achievements
Rank 1
answered on 09 May 2019, 08:15 PM

This operators works when you have a dictionary with object type?

 

Mine is not working as well

0
Dilyan Traykov
Telerik team
answered on 14 May 2019, 02:22 PM
Hi Franciele,

As explained by my colleague Rossen and documented in this article, in case the type of the property is System.Object, but you know that it always returns a “normal” filterable type (such as DateTime), you can “help” the column by setting its DataType property to the correct type.

For your convenience, I've prepared a small sample project which demonstrates a possible approach on handling the AutoGeneratingColumn event when binding the control to a list of DynamicObjects.

If setting this property does not work for you or if you require any further assistance on how to determine its value based on the underlying properties, please further elaborate on your scenario or provide a small sample project demonstrating your current setup and I will happily guide you further.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
T
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
T
Top achievements
Rank 1
Franciele
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or