Tore
Tore

Reputation: 1264

Refreshing rallycombobox after adding new rollup

I have a rallycombobox that is configured to show the Rollups in the current scope:

App.down('#associateWith').add({
    xtype          : 'rallycombobox',
    fieldLabel     : 'Dropdown',
    id             : 'association',
    allowNoEntry   : true,
    storeConfig    : {
        autoLoad       : true,
        model          : 'PortfolioItem/Rollup'
    }
});

This app also has an addnew component that enables users to add a new PortfolioItem/Rollup - If they add a new one, then I want to refresh this combobox to have that rollup as an option as well. I was not able to find a way to refresh the combobox in the API docs, so I am doing the messy version - which involves creating and destroying the combobox quite frequently.

I tried doing a:

setStoreConfig(...);

But that did not seem to refresh the data at all. Any way to accomplish this without destroying and re-creating?

Upvotes: 0

Views: 96

Answers (1)

Matt Greer
Matt Greer

Reputation: 62057

The easiest way to to this is to hook into the AddNew's create event. It will give you a record of the newly created Rollup, and from there you can place it in your ComboBox's store

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',

    launch: function() {
        this.combobox = this.add({
            xtype: 'rallycombobox',
            allowNoEntry: true,
            storeConfig: {
                autoLoad: true,
                model: 'PorfolioItem/Rollup'
            }
        });
        this.add({
            xtype: 'rallyaddnew',
            recordTypes: ['PortfolioItem/Rollup'],
            listeners: {
                create: this._onCreate,
                scope: this
            }
        });

    },

    _onCreate: function(addNew, record) {
        this.combobox.getStore().add(record);
    }
});

Upvotes: 4

Related Questions