This is a migrated thread and some comments may be shown as answers.

Radrotator item time interval

2 Answers 21 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Nathan Perry
Top achievements
Rank 1
Nathan Perry asked on 07 Sep 2013, 03:44 AM
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 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 11 Sep 2013, 12:44 PM
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.
0
Nathan Perry
Top achievements
Rank 1
answered on 11 Sep 2013, 01:39 PM
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
Tags
Rotator
Asked by
Nathan Perry
Top achievements
Rank 1
Answers by
Slav
Telerik team
Nathan Perry
Top achievements
Rank 1
Share this question
or