get_item().get_index()

2 posts, 0 answers
  1. Joe
    Joe avatar
    1 posts
    Member since:
    Nov 2013

    Posted 14 Nov 2013 Link to this post

    Hi Telerik support,


    My client is using telerik control, version 2012...



    We are using RadRotator. I want to get the current showing index. If I retrieve index like:



    function OnClientItemShown( sender, eventArgs)

    {

         alert( eventArgs.get_item().get_index());

    }



    it does not always give the right value. For example, if I have 4 items, showing one item per screen. When it start rotating, the index for the first 3 times will be 0, 1, 2, which is correct. However, the 4th item and that after will always have the index as 2. And I found the returned index is not always stable.



    Another question, when I called clearItems() to delete all items, then call addRotatorItem to add some items back from the client side, when I call start() after these operation, the type is AutomaticAdvance, there are strange behavior for the first time animation. It seems start rotating all items, then rotate to the second item the first time. If I clearItems again, and then add items back. The first time start() it will skip 1 pages. Can you tell me what I should do to get a stable rotating animation after I have clearItems and addRotatorItems?



    Thanks in advance for suggestions.



    Joe

  2. Slav
    Admin
    Slav avatar
    1355 posts

    Posted 19 Nov 2013 Link to this post

    Hello Joe,

    If the function get_index() is not returning the indices in a successive order, please check whether the property EnableRandomOrder of the control is set to true (it will scramble the items when enabled).

    When calling the function AddRotatorItem are you specifying an index, in which the new item is added (the second parameter of the function is used for this purpose)? If you are, I would suggest ensuring that you are ordering the items according to the sequence, in which you want them to show.

    I have prepared a sample page with a RadRotator that performs the described functionality. Please use it as a reference for incorporating the feature into your actual project.

    Note the following line in the example:
    GetRadRotator().get_items()[0]._index = 0;
    It is added because there is a problem with the index of the first item that is inserted after invoking clearItems().

    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