Radrotator item time interval

3 posts, 0 answers
  1. Rami Alshahabi
    Rami Alshahabi avatar
    4 posts
    Member since:
    Aug 2008

    Posted 06 Sep 2013 Link to this post

    Hi

    Let's say, we have many items in the rotator provided from database and each item should be shown for some time different other items in the rotator as en example:

    item 1 for 1 min
    item 2 for 39 second
    item 3 for 2 mins

    Do you think it's possible to work with control? do you advise on other method to achieve this.
    BTW, the time for each item is stored in the database.

    Many Thanks
    Rami
  2. Slav
    Admin
    Slav avatar
    1356 posts

    Posted 11 Sep 2013 Link to this post

    Hi Rami,

    The duration of time each item is displayed in the RadRotator is specified via the frameDuration property. Its value can be controlled through the client-side API of the control, and more specifically the function set_frameDuration.

    Since you have the information stored in a database, you will have to pull it with an Ajax request and then change the frame duration dynamically each time a new item is shown by calling the function, mentioned above, and passing the new duration as a parameter.

    Regards,
    Slav
    Telerik
    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 RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rami Alshahabi
    Rami Alshahabi avatar
    4 posts
    Member since:
    Aug 2008

    Posted 11 Sep 2013 Link to this post

    Hi Slav
    Thank you for getting back to me.
    I found good solution to this and I want to share it with everyone

    First my items are web user controls and they get loaded from
    RadRotator1_ItemDataBound(object sender, RadRotatorEventArgs e)

    {

    DataRowView dataitem = (DataRowView)e.Item.DataItem;

    Control c=LoadControl( dataitem["ControlPath"].ToString());
    // added autorefresh as attributes

    e.Item.Attributes.Add("AutoRefresh", dataitem["AutoRefresh"].ToString());

    e.Item.Controls.Add(c);

    }|
    my JS

     

    function OnClientItemShown(sender, eventArgs) {

     

    var AutoRefresh = GetAttributeValue(eventArgs.get_item(), "AutoRefresh");

     

    var rotator = $find('<%= RadRotator1.ClientID %>');

    rotator.set_frameDuration(AutoRefresh);
    }

     

    function GetAttributeValue(anObject, strProperty) {

     

    if (anObject) {

     

    var attributes = $telerik.$('[' + strProperty + ']:first', anObject.get_element()).attr(strProperty);

     

    if (attributes) {

     

    return attributes;

    }

    }

    }


    Thanks to this  post too.

    Rami
Back to Top