Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
skip values
posted

Is there a way to have the slider skip values.  For instance, I have a slider that is showing DateTime for the next three days to allow a user to select a datetime to return a rental item.  By default it shows 72 hours.  I would like to have the slider skip hours between 6:00 PM and 8:00 AM (hours we are closed).

Is this possible?

  • 24497
    Verified Answer
    posted

    Hi,

    Slider can not remove time from its range. However, it exposes ValueChanging event on client, so application may process that event and cancel it, if new value is not valid for application. In this case moves of thumb within invalid areas will be ignored.

    Application also may create some visual prompts for user, to show which values/ranges are not valid. In order to do that, application should create background images which contain valid and invalid areas and set them to css of track.
    Below is possible example.

    In that example application may create slider/ValueTime.png as rectangles with size ~ 100x10 px. Those images may contain 2 colored areas for a day. Left-gray, right-blue/orange/whatever. Those background images will be repeated by browser for all days (width of track). Of course application should adjust/synchronize widths of those images and left shift (-25px) with Width of slider.

    <style type="text/css">
    .sliderTrack{background:url(./images/sliderTime.png) -25px 0px;}
    .sliderValueTrack{background:url(./images/sliderValueTime.png) -25px 0px;}
    .sliderTransparent{background:transparent;}
    </style>
    <script type="text/javascript">
    function WebSlider1_ValueChanging(sender, eventArgs)
    {
     var oldDate = eventArgs.get_oldValue(), newDate = eventArgs.get_newValue();
     if(newDate.getHours() < 18 && newDate.getHours() > 8)
      return;
     eventArgs.set_cancel(true);
    }
    </script>


    <ig:WebSlider ID="WebSlider1" runat="server" MaxValueAsString="3/13/2010" MinValueAsString="3/10/2010" ValueType="DateTime" Width="376px">
     <Track>
      <CssClasses CssClass="sliderTrack" ValueFillCssClass="sliderValueTrack" LeftOrTopEdgeCssClass="sliderTransparent" RightOrBottomEdgeCssClass="sliderTransparent" />
     </Track>
     <ClientEvents ValueChanging="WebSlider1_ValueChanging" />
     <Tickmarks LabelFormatString="MM/dd" NumberOfLabels="4"
      NumberOfMajorTickmarks="4" NumberOfMinorTickmarks="3">
     </Tickmarks>
    </ig:WebSlider>