PDA

View Full Version : [FIXED] Can't dynamically add items to Carousel and remove all items



johnnywengluu
7 Nov 2011, 11:04 PM
I have a carousel and want to dynamically add items to it.

http://jsfiddle.net/johnnywengluu/29txJ/2/

I get an error message doing that.

Any clue?

UPDATE 1:

It works when carousel already has items[] key: http://jsfiddle.net/johnnywengluu/29txJ/5/

A bug right?

UPDATE 2:

Removing all items in carousel will also output an error:

http://jsfiddle.net/johnnywengluu/29txJ/6/

Bug too?

SunboX
8 Nov 2011, 2:08 AM
Already known Bugs:

http://www.sencha.com/forum/showthread.php?152475-PR1-Creating-an-empty-Ext.Carousel-throws-errors
http://www.sencha.com/forum/showthread.php?152638-PR1-Ext.Carousel.setItems(Array)-doesn%C2%B4t-remove-previous-added-items
http://www.sencha.com/forum/showthread.php?152486-PR1-Ext.Carousel-Removing-an-Item-from-the-Carousel-adds-one-more-Indicator

greetings Sunny

Jamie Avins
8 Nov 2011, 11:03 AM
This has been fixed and will be part of the next release.

johnnywengluu
8 Nov 2011, 2:21 PM
I am a premium member. Where can I get the patch with the bug fixes?

Jamie Avins
9 Nov 2011, 8:32 AM
This will be part of the next preview release, we expect it shouldn't be very long of a wait for it.

Jamie Avins
9 Nov 2011, 11:51 AM
Not that SVN will be updated once we start the beta cycle.

demon222
12 Nov 2011, 5:45 AM
Hi guys.

We're having a similar problem with the carousel.
Fact: when clicking on a list of items, we're moving to a carousel that should dynamically have a certain amount of 'pages' (sorry for the terms) based on the object clicked in the list.

We're working with the lastest PR2 release from yesterday.

Heres the code snippet:


Ext.define('SIMOBILE.view.InvoiceDetail', {
extend: 'Ext.Container',
xtype: 'invoicedetail',
requires: [
'SIMOBILE.view.invoicedetail.Printscreens'
],
config: {
cls: 'cards',
data: null,
layout: {
type: 'card',
align: 'stretch'
},
invoice: null,
autoDestroy: true
},



initialize: function() {

var imageHeight = Ext.Element.getViewportWidth();
if ( Ext.os.deviceType != 'Phone' ) {
this.imageHeight = imageHeight - 250;
} else {
this.imageHeight = imageHeight;
}

this.on({
scope: this,
hiddenchange: this.onHiddenChange
});
},

onHiddenChange: function(me, hidden) {

if (!hidden) {

var carousel = this.down('invoicedetailPrintscreens');
if(carousel != 'undefined') {
carousel.setActiveItem(0);
}
}

},

onHide: function() {

var carousel = this.down('invoicedetailPrintscreens');
this.remove(carousel, true);

},

updateInvoice: function(newInvoice) {

var win = {
xtype:'invoicedetailPrintscreens',
pages: newInvoice.data.bill_pages,
bill_id: newInvoice.data.bill_id,
items: this._generatepanel(newInvoice.data.bill_pages, newInvoice.data.bill_id)
};
this.setItems(win);

},

_generatepanel: function(pages, id) {


var panels = [];

for(i=1;i<=pages;i++) {
panels.push({
scroll: 'vertical',
html:'<img width="100%" src="BASEURLREMOVED/public/invoice/id/'+id+'/type/preview/size/1240/page/'+i+'/token/TOKENREMOVED" />'
});
}


return panels;
}
,
afterRender: function() {

var carouser = this.down('invoicedetailPrintscreens');
carouser.remove();
}
});

Are we doing some kind of logic error?

Regards & thx for your help.

Jamie Avins
14 Nov 2011, 9:28 AM
My guess is that there is currently an open issue with setItems not working properly.