RadSlider - Bind it in a repeater?

7 posts, 1 answers
  1. jgig
    jgig avatar
    61 posts
    Member since:
    Apr 2008

    Posted 05 Sep 2008 Link to this post

    I am trying to bind to a slider in a repeater. I think Im just doing something wrong. Is there a link somewhere I can see this being done? I am using Linq to create the object Im binding to. When I just do:
    <%# DataBinder.Eval(Container.DataItem, "DepartureStartTime")%>
    it displays the value fine so somewhere my binding is off.

    This is what Im trying to do, all values are integers, they say Time but I converted them to minutes
     
    <telerik:RadSlider runat="server" ID="rsArrivalTime" 
    Length="130" IsSelectionRangeEnabled="true" Skin="Inox" 
    SlideStep="1" ShowDecreaseHandle="false" 
    ShowIncreaseHandle
    ="false"   
    SelectionStart='<%#DataBinder.Eval(Container.DataItem, "ArrivalStartTime")%>' 
    SelectionEnd='<%#DataBinder.Eval(Container.DataItem, "ArrivalEndTime")%>' 
    MinimumValue
    ='<%#DataBinder.Eval(Container.DataItem, "ArrivalStartTime")%>' 
    MaximumValue='<%#DataBinder.Eval(Container.DataItem, "ArrivalEndTime")%>'/>  
     



    -thanks

  2. jgig
    jgig avatar
    61 posts
    Member since:
    Apr 2008

    Posted 07 Sep 2008 Link to this post

    not sure what the problem is but I've been playing around a bit with the use of 2 RadTimePicker's instead of the range slider. Since my rangeslider values never get set properly (see above).

    I can set the SelectedDate of the RadTimePicker but I can not change the TimeView.StartTime or TimeView.EndTime after I bind to the repeater. I was going to dynamically set these (still would like to bind them as well) so that any time that was out of range couldnt be selected. If I set the values in the ASPX page they are fine. But when I loop through the repeater and set their values after the control is already loaded they never change.

    Is the big problem that this needs to be done page load? That will be a problem since I dont have the data in this control yet until they do a search. I could see about loading the control dynamically after they do a search but that would be a pain with lots of rework to the page.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Petko
    Admin
    Petko avatar
    45 posts

    Posted 08 Sep 2008 Link to this post

    Hello Jgig,

    We tried the example below where the RadSlider(with IsSelectionRangeEnabled="true") is in Repeater controls  and everything is OK.
    ASPX:
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik"%> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server">  
        <title>Untitled Page</title> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <asp:ScriptManager runat="server" ID="ScriptManager"></asp:ScriptManager> 
        <div> 
       
        <asp:Repeater runat="server" ID="Repeater1">  
             <ItemTemplate> 
                <div> 
                <telerik:RadSlider ID="RadSlider1" runat="server" IsSelectionRangeEnabled="true" 
                SelectionStart='<%#DataBinder.Eval(Container.DataItem, "Value1")%>'   
                MinimumValue='<%#DataBinder.Eval(Container.DataItem, "Value1")%>'   
                SelectionEnd='<%#DataBinder.Eval(Container.DataItem, "Value2")%>'   
                MaximumValue='<%#DataBinder.Eval(Container.DataItem, "Value2")%>'   
                /> 
                </div> 
                <div style="clear:both"></div> 
                </ItemTemplate> 
                  
        </asp:Repeater> 
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> 
        </div> 
        </form> 
    </body> 
    </html> 
     
    Codebehind:
      protected void Page_Load(object sender, EventArgs e)  
        {  
            DataTable table = new DataTable();  
            DataColumn column1 = new DataColumn("Value1", Type.GetType("System.Int32"));  
            DataColumn column2 = new DataColumn("Value2", Type.GetType("System.Int32"));  
            table.Columns.Add(column1);  
            table.Columns.Add(column2);  
              
            DataRow row1 = table.NewRow();  
            row1[0] = 10;  
            row1[1] = 200;  
            table.Rows.Add(row1);  
              
            DataRow row2 = table.NewRow();  
            row2[0] = 20;  
            row2[1] = 150;  
            table.Rows.Add(row2);  
     
            DataRow row3 = table.NewRow();  
            row3[0] = 20;  
            row3[1] = 250;  
            table.Rows.Add(row3);  
              
     
            Repeater1.DataSource = table;  
            Repeater1.DataBind();  
     
              
              
        } 

    If you still experience problems to bind a Repeater which contains a RadSlider, please open a new support thread and send us a runnable project where we can observe this problem. Once we receive it we will do our best to help you.

    Sincerely yours,
    Petko
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. jgig
    jgig avatar
    61 posts
    Member since:
    Apr 2008

    Posted 08 Sep 2008 Link to this post

    I tried you code on a test page and yes it works. But when I put it on my user control it does not. I think the difference is yours is in the Page Load and mine is not. I have a page with 2 controls on it, one control initiates a function on the second and it renders the radsliders and etc. I put your code there and it has the same problem. The sliders are never set to the selection start or end.
  6. jgig
    jgig avatar
    61 posts
    Member since:
    Apr 2008

    Posted 08 Sep 2008 Link to this post

    I created a ticket with a sample project - ticket ID is : 160543
  7. Answer
    Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 10 Sep 2008 Link to this post

    Hello jgig,

    I just answered your ticket. For convenience I am pasting my reply below:

    This is a known bug with RadSlider that appears when IsSelectionRangeEnabled="true" and the slider has a parent element set with display:none. In such scenario, the slider will not be rendered correctly if the parent element become visible.

    We fixed this bug and the fix will be available in next RadControls for ASP.NET AJAX official release. The good news is that there is a workaround that handles RadSlider OnClientLoaded event which invokes updated() and repaint() methods, e.g.
     
    FareSearchList  
     <script type="text/javascript">  
        function SliderLoaded(obj,args)  
        {  
            setTimeout(function()  
            {   
              obj.repaint();  
              obj.updated();  
            },0);  
        }  
        </script> 
    <asp:Repeater runat="server" ID="Repeater1">     
         <ItemTemplate>    
            <div style="height:30px;">  
                <telerik:RadSlider ID="RadSlider1" Skin="WebBlue" runat="server" IsSelectionRangeEnabled="true"    
                    SelectionStart='<%#DataBinder.Eval(Container.DataItem, "Value1")%>' 
                    MinimumValue='<%#DataBinder.Eval(Container.DataItem, "Value1")%>' 
                    SelectionEnd='<%#DataBinder.Eval(Container.DataItem, "Value2")%>' 
                    MaximumValue='<%#DataBinder.Eval(Container.DataItem, "Value2")%>' 
                    OnClientLoaded="SliderLoaded"/>  
            </div> 
        </ItemTemplate>    
    </asp:Repeater> 



    Best wishes,
    Petio Petkov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. jgig
    jgig avatar
    61 posts
    Member since:
    Apr 2008

    Posted 10 Sep 2008 Link to this post

    Thank you! works now
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017