View Full Version : MVC: adding components to viewport

21 Dec 2010, 4:11 PM
I have a dynamic list of products to add to the viewport and I may not know ahead of time what list of products I might be showing to the user. Therefore I've wrapped logic in my view to dynamically create a store based on a categoryId.

So essentially when I get a new Id, I need to add a new version of the view, hand it the new categoryId, and it will handle setting up the store for the list.

So in order for this to work out, I need to re-add the panel (with a list in it) to the viewport. Is this legit code?
I've checked the item collection of the viewport but it doesn't look like instances of productListPanel are piling up in there. I'm assuming that somehow the viewport knows to remove a previous version of this xtype before creating the new one.

* Load product list panel
* Assumption: Adding a new productListPanel first removes the previous
* created panel and replaces it with a new one.
getProductList: function(options) {
var categoryId = options.category;

var productListPanel = this.render({
xtype: 'productListPanel',
categoryId: categoryId

Ext.getCmp('viewport').cardSwitchAnimation = {
type: 'slide',
direction: 'right'