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

DateTime Filtering Not Working

3 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Trevor
Top achievements
Rank 1
Trevor asked on 29 Apr 2011, 05:31 PM
I have created a simple test to check to see if the date is properly filtering and it seems to be failing every time when I have two dates with different years ... Please look at this code and test it and let me know what I am doing wrong if anything.
<telerik:RadGrid ID="gridUsers" AllowAutomaticDeletes="true" runat="server" AllowPaging="true" AllowSorting="true" AllowFilteringByColumn="true" PageSize="10" AutoGenerateColumns="false">
                        <GroupingSettings CaseSensitive="false" />
                        <HeaderStyle Font-Bold="true" />
                        <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" Visible="true" EnableSEOPaging="true"/>
                        <ClientSettings>
                            <Scrolling AllowScroll="False" />
                        </ClientSettings>
                        <MasterTableView CommandItemDisplay="Top" AllowNaturalSort="false" DataKeyNames="Created">
                            <Columns>
                                <telerik:GridDateTimeColumn HeaderText="Created" ItemStyle-Wrap="false" UniqueName="Created" DataField="Created" FilterListOptions="VaryByDataType" FilterImageUrl="~/images/filter_icon.gif" />
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
Protected Sub gridUsers_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles gridUsers.NeedDataSource
        Dim myDT As New DataTable
        myDT.Columns.Add("Created")
  
        Dim row1 As DataRow = myDT.NewRow
        row1("Created") = Date.Now
  
        Dim row2 As DataRow = myDT.NewRow
        row2("Created") = Date.Now.AddDays(12)
  
        Dim row3 As DataRow = myDT.NewRow
        row3("Created") = Date.Now.AddYears(-2)
  
        Dim row4 As DataRow = myDT.NewRow
        row4("Created") = Date.Now.AddYears(-3)
  
        myDT.Rows.Add(row1)
        myDT.Rows.Add(row2)
        myDT.Rows.Add(row3)
        myDT.Rows.Add(row4)
  
        gridUsers.DataSource = myDT
    End Sub

The first bit is my code behind for the datasource of the grid and the second is the asp code. Try and filter something like "1/1/2010" without the quotes and place the filter on less then and the results come back empty. The inverse being greater then where the no filtering occurs.

Please help asap,
Thanks!
Trevor

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 30 Apr 2011, 06:29 AM
Hello Trevor,

Try to set EnableLinqExpressions=false.
aspx:
<telerik:RadGrid  ID="RadGrid1"  runat="server"  EnableLinqExpressions="false". . . . .

Thanks,
Princy.
0
Trevor
Top achievements
Rank 1
answered on 04 May 2011, 10:31 PM
Princy.,

thanks for you response however, this does not work either. If you copy the code I have given you can see this for yourself. If I filter 1/1/2011 with the filter "greaterthan" I still return all results when two of them are obviously before 2011.

Any suggestions here?

Thanks,
Trevor
0
Princy
Top achievements
Rank 2
answered on 05 May 2011, 08:18 AM
Hello Trevor,

I tried to replicate the same scenario and it is working fine on my end. Check the following demo and check whether it suits your needs.
Grid / Basic Filtering.

Thanks,
Princy.
Tags
Grid
Asked by
Trevor
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Trevor
Top achievements
Rank 1
Share this question
or