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

RadRotator HowTo Questions

4 Answers 197 Views
Rotator
This is a migrated thread and some comments may be shown as answers.
Cole
Top achievements
Rank 1
Cole asked on 28 Nov 2008, 04:37 PM
Hey there,

Working with radrotator similar to the image gallery example shown on your website.  2 things I am wondering...

1. how can i detect the current items shown out of the array?  Preferably on the client side, but if not, server-side is fine too.  That is, if I have 27 items and the room to show 4 at a time... how could i tell as I rotate through them which is the start/end items in my list?
e.g. I want to have "Now showing 5 to 9 of 27" text below my rotator.  I want the '5'/'9' numbers to be updated either on Page_Load (initially) or after I move the screen left/right one.   Anyone know how to do this?

2. Supposing the '5' in the example above was actually a text box the user could type in and hit <ENTER> to set the starting item... how could I do this? 
Edit: 1 more question related to the radrotator...

1. In OnItemclick server-side event, the rotator seems to reset to the first item in the list.  How can I set it to stay at the current frame.  E.g. if I show 4 items at once and have moved over 7, how can I set it up that if I click on the 3rd item, it is in 3rd position of the visible elements in the rotator on page postback.


Thx,
Rob

4 Answers, 1 is accepted

Sort by
0
Cole
Top achievements
Rank 1
answered on 01 Dec 2008, 04:24 PM
Anyone have thoughts on these questions? 
0
Accepted
Lini
Telerik team
answered on 02 Dec 2008, 03:26 PM
Hello Rob,

1. You can use the rotator client API to count the items as they are scrolled into view. For example if the scroll direction is left, you increase the current item number by one, if the scroll direction is right - decrease by one. You can do this by using the OnClientItemShown event.

2. You can do this with the InitialItemIndex server rotator property. Set the property to the index of the first item you wish to show (e.g. 5) and the rotator will position this item at the beginning of the viewport.

3. Again you can do that with the InitialItemIndex property. The server OnItemClick event has a reference to the clicked item and its index, which you can use to set the InitialItemIndex.

All the best,
Lini
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Cole
Top achievements
Rank 1
answered on 03 Dec 2008, 02:54 PM


This is my javascript method that gets called for onClientItemShown method in my rotator... it tracks the first item achieving the functionality I wanted... just sharing it.

One question though... trial and error allowed me to see the allowable values for the get_animationDirection()... are these stored as constants at all?  I hate the "== 2" I am using.

Thx,
Rob



   function previewItemShown(sender, args)
        {
            var change = (sender.get_animationDirection() == 2)?-1:1;
            var hiddenElement = document.getElementById("<%= PreviewStripIdx.ClientID %>");
             var currentIdx = parseInt(hiddenElement.value);
                        
            var totalItems = parseInt(document.getElementById("<%=TotalNumberOfPhotosInStrip.ClientID %>").value);

           
            var newIdx = currentIdx + change;
            
            if (newIdx < 0)
                newIdx = totalItems - 1;
            else if (newIdx >= totalItems)
                newIdx = 0;

            hiddenElement.value = newIdx;            
        }
0
Lini
Telerik team
answered on 04 Dec 2008, 12:14 PM
Hi Rob,

Yes, the directions are stored in the Telerik.Web.UI.RotatorScrollDirection enum on the client. You can use Telerik.Web.UI.RotatorScrollDirection.Left, .Right, .Up, or .Down.

Regards,
Lini
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Rotator
Asked by
Cole
Top achievements
Rank 1
Answers by
Cole
Top achievements
Rank 1
Lini
Telerik team
Share this question
or