Sonalkumar sute
Sonalkumar sute

Reputation: 2575

save the selected options rally

I have one Rally Sdk2 app, which has chooserDialog box. Which displays programs, I can select multiple programs and click filter then it displays the features for those programs but, when I again came to same dialog it does not store the last choices I made.. I tried stateful, but I am not getting it correct, below is my Dialog

enter image description here

And below is my ChooserDialog code

            _run: function() {
                var me = this;
                Ext.create('Rally.ui.dialog.ChooserDialog', {
                    width: 470,
                    autoScroll: true,
                    height: 500,
                    title: 'Select to Filter',
                    pageSize: 100,
                    closable: false,
                    selectionButtonText: 'Filter', 
                    itemId: 'chooser',
                    multiple: true, 
                    setMultiple: true,
                    artifactTypes: ['PortfolioItem/Program','PortfolioItem/Epic','PortfolioItem/MMF'],
                    autoShow: true,
                    stateful: true,
                    stateId: 'selected-pi',
                    stateEvents: ['click','statesave'],
                    storeConfig:{
                        fetch: ['Name','PortfolioItemTypeName', 'Parent']
                    },
                    listeners: {
                        scope: me,
                        artifactChosen: function(selectedRecord) {
                            //this.down('#chooser').setValue(selectedRecord);
                            var filters = me._getFilters(selectedRecord);
                            me._drawCardBoard(me, filters);
                        }
                    }
                });
            },  

Upvotes: 1

Views: 101

Answers (2)

nickm
nickm

Reputation: 5966

I did not try State, but localstorage can be used to set default values:

localStorage.setItem('MyComboboxValue',Ext.getCmp('MyCombobox').getValue());

and get default values by setting value config property of the component to the value returned by:

value: localStorage.getItem('MyComboboxValue')

See a full code example of saving selections in comboboxes and checkboxes via localstorage in this github repo. The choices are retained after the page is reloaded.

UPDATE: I tried to make ArtifctChooserDialog remember selections, but it turns out that this code will not work in case of multiple selections when multiple: true due to a bug that Kyle identified.

Ext.define('CustomApp', {
    extend: 'Rally.app.App',
    componentCls: 'app',
    _selected: [],
    stateful: true,
    getState: function(){
        return{
            selectedRef: this.selectedRecord
        }
    },
    launch: function() {
        var that = this;
        Ext.create('Rally.ui.dialog.ArtifactChooserDialog', {
            itemId: 'dialog',
            autoShow: true,
            multiple: true,
            artifactTypes: ['PortfolioItem/Theme','PortfolioItem/Initiative','PortfolioItem/Feature'],
            storeConfig:{
                fetch: ['Name','PortfolioItemTypeName']
            },
            listeners: {
                scope: this,
                artifactchosen: function(dialog, selectedRecord) {
                    this._selected.push(selectedRecord);
                    console.log(selectedRecord);
                    //this.selectedRecord = dialog.getSelectedRef();
                    this.selectedRecord = Rally.util.Ref.getRelativeUri(selectedRecord);
                    this.saveState();

                }
            },
            selectedRef: this.selectedRef
        });
    }
});

Upvotes: 1

Kyle Morse
Kyle Morse

Reputation: 8410

This may or may not be possible in the rc builds of the SDK. We just made the new 2.0 version available and it has full support for the stateful mixin now.

There is even a guide for how to implement it:

http://help.rallydev.com/apps/2.0/doc/#!/guide/state

Also please note that the ChooserDialog is considered deprecated. The ArtifactChooserDialog should be a mostly drop-in replacement however.

Upvotes: 1

Related Questions