Radrotator Items/Frames Count

2 posts, 0 answers
  1. Rahul
    Rahul avatar
    7 posts
    Member since:
    Dec 2013

    Posted 16 Jan 2014 Link to this post

    Hi,
           The below mention is the radrotator controls which I have created.  
    Javascript

    <script type=
    "text/javascript">
        function OnClientButtonClick(sender, args) {
    //        debugger;
            var currentIndex = sender.get_currentItem().get_index();
            var count = sender.get_items().length;
            var frames = Math.ceil(count / 3);
            var tot = 1;
                if (currentIndex % 3 == 0) {
                    tot = 2 + (sender.get_currentItem().get_index() / 3);
                }
                else if (currentIndex == 0)
                    tot = 1;
            var com = tot + '/' + frames;
            document.getElementById('<%= this.Label1.ClientID %>').innerHTML = com;
        }
    </script>
    <telerik:RadRotator ID="ImageStrip_RadRotator" InitialItemIndex="0" runat="server" RotatorType="CoverFlowButtons" >
                        <ItemTemplate>
                            <telerik:RadBinaryImage ID="RadBinaryImage1" CssClass="itemTemplate" runat="server" DataValue='<%# Eval("Photo") == DBNull.Value? new System.Byte[0]: Eval("Photo") %>'
                                AutoAdjustImageControlSize="false" />
                        </ItemTemplate>
                        <ControlButtons OnClientButtonClick="OnClientButtonClick" />
                    </telerik:RadRotator>

       I have given the rotator dimensions and rotator type in .cs file,which is working fine. The rotator shows 3 images per frame.Suppose if there are 7 images then 3 frames will be shown. I'm getting the number of frames from "Var Frames" in the script.
      What I want is that how to find the current frame if i move the left/right button in rotator  ? I have attached a screenshot also.
    If you are not able to find out the current frame, can you tell me this with respect to number of images in the rotator and the current image in focus. I'm looking for a javascript.


    Regards
    Rahul
  2. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 21 Jan 2014 Link to this post

    Hello Rahul,

    You can use the following line, in which sender is the client-side object of the RadRotator, as you did in your script, however I would suggest doing so in the event OnClientItemShown instead of OnClientButtonClick, because it is fired when the current item index is updated:
    sender.get_currentItem().get_index()

    Once you have the index, you can determine which is the currently displayed item.

    I hope this helps. Feel free to contact us again if you are still having difficulties or if I am missing something.

    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
Back to Top