Filtering by Date only using RadFilter

8 posts, 0 answers
  1. Scott
    Scott avatar
    11 posts
    Member since:
    Jun 2007

    Posted 05 Jul 2010 Link to this post

    I'm having some issues with the RadFilter.

    I'm using an Image Folder as a datasource and using the following command to pull all the DataFields within the folder;

    Dim dirInfo As New DirectoryInfo(Server.MapPath("~/GalleryFiles"))

    RadListView1.DataSource = dirInfo.GetFiles("*.jpg")
    RadListView1.DataBind() 

    from all the possible DataFields I'm only using the "Name" and "LastWriteTime" Fields. I want to be able to use the "LastWriteTime" field and filter it purely based on the date it pulls. Is there a way to get RadFilter to ignore the Time parameter as images will be created regularly and the time filter is too precise.

    Any feedback would be much appreciated.

    Thank you 


  2. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 07 Jul 2010 Link to this post

    Hello Jason,

    For your convenience I've prepared sample application demonstrating one possible way of changing default filtering behavior. In general you can change the filtering on DateTime to between filtering and adding 1 minute(in current example) to original value.

    Greetings,
    Nikolay
    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
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Scott
    Scott avatar
    11 posts
    Member since:
    Jun 2007

    Posted 07 Jul 2010 Link to this post

    In your attached example I am still unable to filter results by date only with the LastWriteTime field. If I choose the date 7/7/2010 The TimePicker defaults the time as 00:00, the fiter removes all results due to their time stamp being 14:26. I would like to exclude the time from the filter completely.

    I have tried a Between version also, using your demo examples for the RadGrid Filter templates. Every time I pick a date the page posts back and resets the selected date to the focused date. 
  5. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 12 Jul 2010 Link to this post

    Hello Jason,

    You can change the following code to add one day instead one of minute as in my previous example:
    ..
    RadListViewLessThanOrEqualToFilterExpression<DateTime> lt = new RadListViewLessThanOrEqualToFilterExpression<DateTime>(expression.FieldName)
    {
      CurrentValue = value.AddDays(1)
    };
    ..


    All the best,
    Nikolay
    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
  6. Scott
    Scott avatar
    11 posts
    Member since:
    Jun 2007

    Posted 12 Jul 2010 Link to this post

    Thank you,

    I am building using vb.net, will this code translate ok?

    Also.. is it possible to tidy up I.e remove items from the drop down list that displays directory elements to only show Lastwrite time and name?

    Regards
    J
  7. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 14 Jul 2010 Link to this post

    Hello Jason,

    For your convenience I am attaching VB version of the code + JavaScript code for hiding items from RadFilter context menu.

    All the best,
    Nikolay
    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
  8. Scott
    Scott avatar
    11 posts
    Member since:
    Jun 2007

    Posted 20 Jul 2010 Link to this post

    Hi

    Would it be possible to help show me how I could get a radrotator bound with the file array after the date has been chosen. I have a working example as supplied with a standard calendar control but cannot integrate this using the radfilter as supplied.

     

     

    Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)

     

     

     

     

    Dim dir As New DirectoryInfo(Server.MapPath("~/GalleryFiles/Camera1"))

     

     

     

    Dim files As FileInfo() = dir.GetFiles("*.thumbnail.jpg")

     

     

     

    Dim count As Integer = files.Length

     

     

     

    Dim i As Integer

     

     

     

    Dim jFiles As String

     

     

     

    Dim dt As String

     

    dt = Calendar1.SelectedDate.ToShortDateString()

     

     

     

    ' holds the result, which will be used in order to rebind the RadRotator control

     

     

     

    Dim resultDataSource As List(Of String) = New List(Of String)()

     

     

     

     

    For i = 0 To count - 1

     

     

     

    Dim theDate As Integer = DateDiff(DateInterval.Day, files(i).LastWriteTime, Calendar1.SelectedDate)

     

     

     

    Dim virtualPath As String = "~/GalleryFiles/Camera1"

     

     

     

     

    If theDate = 0 Then

     

    jFiles = jFiles &

     

    "<li><img style="" width:50px"" src='../GalleryFiles/Camera1/" & files(i).Name.Substring(0, 16) & ".jpg'' ><a href='../GalleryFiles/Camera1/" & files(i).Name.Substring(0, 16) & ".jpg'>" & files(i).Name.Substring(0, 16) & " " & files(i).LastWriteTime.Date & "</a></li>"

     

     

     

     

    ' Add the files in the new DataSource

     

     

     

    'resultDataSource.AddRange(dir.GetFiles(files(i).Name))

     

     

     

    'resultDataSource.Add(files(i).Name)

     

    resultDataSource.Add(files(i).Name.Substring(0, 16))

     

     

    End If

     

     

     

    Next

     

     

     

     

    ' Rebind the control

     

     

     

    ' If no files are found, thne the RadRotator will contain 0 items and will not show any content

     

    RadRotator1.DataSource = resultDataSource

    RadRotator1.DataBind()

     

    list.Text =

     

    "</ul>" & jFiles

     

    Label1.Text = dt

     

     

    End Sub





    PS. Thank you very much for the most recent help.

    J

     

  9. Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 23 Jul 2010 Link to this post

    Hello Jason,

    If I understand your scenario correctly, you are trying to filter against RadRotator. If this is the case you can use the following approach.
    1. Define in FieldEditors for RadFilter
     2. Build custom provider that will process expressions in for DateTime in expected for your scenario way
     3. Handle ApplyExpressions event of RadFilter to apply the filter criteria on RadRotator data source. For the purpose you can use the help of DynamicLinq.

    For your convenience I am attaching sample application demonstrating described above case.

    Regards,
    Nikolay
    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017