Do you have a demo of the Slider using a date range?

3 posts, 0 answers
  1. Brent Hetland
    Brent Hetland avatar
    61 posts
    Member since:
    Aug 2009

    Posted 05 Feb 2014 Link to this post


    I am using version Q3 1114 2013 of your controls.

    I want to use the slider for a date range, where the start and end dates vary so they have to be set at runtime.

    I want to show ticks of the dates between the start and end date range, so the user will be able to see the timeline.  I am currently using SmallChange="7" and LargeChange="28" so that each small change is a week and each large change is 4 weeks.

    If I understand correctly, I need to set ItemType="Item" and then add RadSliderItems to create the ticks.

    Of course since I don't have a fixed date range, I will have to add RadSliderItems at runtime as well.

    I have the slider working correctly until I programatically add the RadSliderItems.  If I add the RadSliderItems programatically, the RadSlider's SelectionStart and SelectionEnd are no longer set correctly.  Instead of them being set to the leftmost and rightmost dates in the range, they are both set to the far right.

    My first question is:  Do you have an example of doing this?  Please don't refer me to your online demo for adding RadSliderItems.  It doesn't show how to do all of this programatically using dates.

    Here is my code.  Can you tell me what I might be doing wrong, that would cause my SelectionStart and SelectionEnd to be wrong when I add my RadSliderItems?
    If I comment out the code that adds the RadSliderItems, the code below that (that sets the minimum / maximum / selectionstart / selectionend) works fine and the slider works fine.

    Dim firstDate As Date = Today
    Dim lastDate As Date = Today

    If (Not Page.IsPostBack) Then
    firstDate = filteredTaskList(0).apTaskPlannedStart
    lastDate = filteredTaskList(filteredTaskList.Count - 1).apTaskPlannedEnd

    Do Until firstDate >= lastDate
    Dim rsi As New RadSliderItem(firstDate.ToShortDateString, firstDate.ToShortDateString)
    firstDate = firstDate.AddDays(28)
    End If

    If (Not Page.IsPostBack) Then
    RadSlider1.MinimumValue = CInt(filteredTaskList(0).apTaskPlannedStart.ToOADate)
    RadSlider1.MaximumValue = CInt(filteredTaskList(filteredTaskList.Count - 1).apTaskPlannedEnd.ToOADate)

    RadSlider1.SelectionStart = CInt(filteredTaskList(0).apTaskPlannedStart.ToOADate)
    RadSlider1.SelectionEnd = CInt(filteredTaskList(filteredTaskList.Count - 1).apTaskPlannedEnd.ToOADate)
    filteredTaskList = From tasks In filteredTaskList _
     Where tasks.apTaskPlannedStart >= Date.FromOADate(RadSlider1.SelectionStart.ToString) AndAlso tasks.apTaskPlannedEnd <= Date.FromOADate(RadSlider1.SelectionEnd.ToString) _
     Select tasks
    End If

  2. Slav
    Slav avatar
    1359 posts

    Posted 10 Feb 2014 Link to this post

    Hello Brent,

    Please check the following demo about Items in RadSlider: As described the properties Value, SelectionStart and SelectionEnd of a slider that uses Items represent the index in the Items collection of the currently selected slider item or items. For example, if there are four items in the slider and you want the selection to start from the first item and to end at the last one, you would set SelectionStart = 0 and SelectionEnd = 3, because these are the indices of the first and the last item.

    In your case you are setting SelectionStart and SelectionEnd with values of items instead of with their indices, and the slider positions the drag handles at the end because it cannot find an item with greater index.

    If you want to configure the start and the end of the selection to the start and end item, I would suggest keeping SelectionStart always to 0 and SelectionEnd to the item count minus 1 (the index of the last item).

    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the UI for ASP.NET AJAX, subscribe to the blog feed now.
  3. Brent Hetland
    Brent Hetland avatar
    61 posts
    Member since:
    Aug 2009

    Posted 11 Feb 2014 in reply to Slav Link to this post

    Thanks Slav, I should have caught that...  I've got it working now.
Back to Top