View Full Version : How to get count/length of items in a carousel component?

3 Nov 2011, 9:26 PM
Hi All,

How can we get count/length of carousel component in sencha touch 2.0 since 'items' property was depreciated in ST2.0 PR1?

I am using Sencha Touch 2.0 with MVC architecture.

Advance thanks to all...

4 Nov 2011, 3:07 AM
Hi prm.
In ST2 you have the getter function now, so you only need to call


on your carousel component to know how many items your carousel contains.

Hope this helps.

6 Nov 2011, 9:52 PM

thanks for your help.

When I used that one, I'm getting an error as follows,

Uncaught TypeError: Cannot call method 'getItems' of undefined.!!!

Please go through the code given below. This is the controller code used in the application:

Ext.define('Sencha.controller.Main', {
extend: 'Ext.app.Controller',

views: ['Home', 'Products', 'Contact', 'Article','LatestArticles','ContentList', 'ContentCarousel'],

refs: [
ref: 'contactForm',
selector: '#contactForm'
ref: 'articlesPage',
selector: '#articlespage'

stores: [
'Mains', 'Contentlist'

init: function() {
'button[action=submitContact]': {
tap: 'submitContactForm'

Ext.Msg.alert("Count->>>", this.getArticlesPage().getItems().length, function(){});

submitContactForm: function() {
var form = this.getContactForm();

url: 'contact.php'

please check the highlighted part of code with red color and let me know.

7 Nov 2011, 12:03 AM
Hi pm.
Your problem is essentially the one which I have already replied in the following post, so this post has been duplicated.

http://www.sencha.com/forum/showthread.php?153459-How-can-we-access-objects-of-inner-components&p=669487#post669487 (http://www.sencha.com/forum/showthread.php?153459-How-can-we-access-objects-of-inner-components&p=669487#post669487)

So please, reply to that one because I'm going to close this.
Thank you.