Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Highlighted
Developer
Posts: 135
Registered: ‎04-25-2009
My Device: Z30
My Carrier: AT&T
Accepted Solution

Programmatic list scrolling not working

For some very odd reason, i am unable to programmaticaly scroll my list. With the exception of using the simple scroll() method which takes a pixel offset, none of the other scrolling methods do anything.

 

Also, ScrollPosition and ScrollAnimation which hold constants, are seemingly unavailable for my use. When I do ctrl+space to see hints, the only suggestions are ScrollIndicatorMode and ScrollMode.

http://developer.blackberry.com/cascades/reference/bb__cascades__scrollposition.html

 

 

ActionItem {
                        title: "To Top"
                        ActionBar.placement: ActionBarPlacement.InOverflow
                        imageSource: "asset:///images/ic_to_top.png"
                        onTriggered: {
                            messagesList.scrollToItem(1);
                        }
                    },
                    ActionItem {
                        title: "To Bottom"
                        ActionBar.placement: ActionBarPlacement.InOverflow
                        imageSource: "asset:///images/ic_to_bottom.png"
                        onTriggered: {
                            messagesList.scrollToItem(messagesList.dataModel.childCount());
                        }
                    },

 

 Since I couldnt access the constants needed for scrollToPosition() method, I tried using the scrollToItem() which scrolls to a provided index number. This does absolutely nothing.

 

Please, any suggestions help is welcome and appreciated.

Thanks!

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Programmatic list scrolling not working

[ Edited ]

Hi,
scrollToItem expects an indexPath which is a JavaScript array consisting of section and item number. Indexes are zero based. Try:

messagesList.scrollToItem([1]) // second item
or
messagesList.scrollToItem([0, 1]); // first section, second item
I'm not sure which one will work.

childCount returns a number of child items in section and takes an argument. For ArrayDataModel or GroupDataModel use size() function instead. Valid item range is 0..size()-1.


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 135
Registered: ‎04-25-2009
My Device: Z30
My Carrier: AT&T

Re: Programmatic list scrolling not working

Thank you so much!!! Working perfectly now.