Results 1 to 3 of 3

Thread: Problem with ux.MultiSelect.js

  1. #1
    Sencha User
    Join Date
    Jul 2009
    Location
    Dallas, TX
    Posts
    5

    Default Problem with ux.MultiSelect.js

    I'm getting an error when the setValue() method is called in the MultiSelect.js file off of the initial loading of the page. I have a multiselect control which has a predefined values that are returned in json format. I get the following error when the page tries to load:

    Error states:
    this.view is undefined - /scripts/ext-3.0.0/ux/MultiSelect.js --- Line 243
    Here is the code in MulitSelect.js (red line is the where the error occurs):
    Code:
    setValue: function(values) {
            var index;
            var selections = [];
            this.view.clearSelections(); // it fire bug says this.view is undefined.
            this.hiddenField.dom.value = '';
    
            if (!values || (values == '')) { return; }
    
            if (!Ext.isArray(values)) { values = values.split(this.delimiter); }
            for (var i=0; i<values.length; i++) {
                index = this.view.store.indexOf(this.view.store.query(this.valueField,
                    new RegExp('^' + values[i] + '$', "i")).itemAt(0));
                selections.push(index);
            }
            this.view.select(selections);
            this.hiddenField.dom.value = this.getValue();
            this.validate();
        },
    Here is my code for the multiselect:

    Code:
    {
        xtype: 'multiselect',
        fieldLabel: 'Products <br /><i>Press ctr and click</i>',
        name: 'Products__c',
        width: 250,
        height: 110,
        allowBlank:false,
        store: [['Angel', 'Angel'], ['Opportunity', 'Opportunity'], ['RIA', 'RIA'], ['Venture Capital', 'Venture Capital']],
        tbar:[
            {
                text: 'Clear selection...',
                handler: function(){
                    company.getForm().findField('Products__c').reset();
                }
            },
            {
                text:"test",
                handler:function(){
                    company.getForm().findField("Products__c").setValue("Angel,Opportunity");
                }
            }
        ]
        //,ddReorder: true
    },
    And here is my json data that is returned to load the form...

    Code:
    {success:true,data:{"Id":"","Name":"Test Company No. 2","Entity_Class__c":"Deal / Investment Company","Executive_Summary__c":"test exect for test 2","Mission_Statement__c":"test mission for company 2","Commitment_Term_In_Months__c":"12.0","Description_of_Opportunity__c":"test description for company no 2","Final_Close_Date__c":"2009-11-10","Fund_Raising_Target__c":"1000000.0","Maximum_Commitment_Amount__c":"20000.0","Opportunity_Open_Date__c":"2009-07-10","Return_Percentage__c":"15.0","Website__c":"www.test.com","Business_Origination_Date__c":"2009-06-10","Number_of_Employees__c":"13.0","Incorporation_State__c":"TX","Industry__c":"Technology","Opportunity_Status__c":"Open","Products__c":"Angel,Opportunity","Risk_Level__c":"Medium","Strategy__c":"Energy and Power,Infrastructure","Type_of_Business__c":"Private","Type_of_Investment__c":"Distressed Situation,Growth Capital","Associated_Company__c":"a1D40000000CbbgEAC","Primary_Contact__c":"0034000000YOy3GAAT","Mailing_Address_1__c":"123 Two Ln","Mailing_Address_2__c":"Suite 200","Mailing_City__c":"Dallas","Mailing_State__c":"TX","Mailing_Zip__c":"75889","Mailing_Country__c":"US","Shipping_Address_1__c":"321 Two Ln","Shipping_Address_2__c":"Suite 2","Shipping_City__c":"Dallas","Shipping_State__c":"TX","Shipping_Zip__c":"75889","Shipping_Country__c":"US"}}
    I put a test button in to see if I could run setValue() after the control was rendered and it works fine for setting the selected items. So, the problem has to be that the multiselect control is not completely rendered or something because "this.view" is undefined.

    How can I make sure that the view in the Multiselect.js is set before the setValue function is called?

  2. #2
    Sencha User
    Join Date
    Apr 2007
    Location
    NH
    Posts
    3

    Default

    I had the same issue today.
    I modified the multiselect code to set the values after its rendered.

    Code:
    onRender: function(ct, position){
    ...
            this.view.on('afterrender', this.loadSelectedValues, this);
    ...
    }
    
    setValue: function(values) {
            var index;
            var selections = [];
            if (this.view)
            {
                this.view.clearSelections();
                this.hiddenField.dom.value = '';
    
                if (!values || (values == '')) { return; }
    
                if (!Ext.isArray(values)) { values = values.split(this.delimiter); }
                for (var i=0; i<values.length; i++) {
                    index = this.view.store.indexOf(this.view.store.query(this.valueField,
                        new RegExp('^' + values[i] + '$', "i")).itemAt(0));
                    selections.push(index);
                }
                this.view.select(selections);
                this.hiddenField.dom.value = this.getValue();
                this.validate();
            }
            else
            {
                this.valuesToSet = values;
            }
        },
    
        loadSelectedValues: function(view){
            if (view && this.valuesToSet)
            {
                this.setValue(this.valuesToSet);
                this.valuesToSet = null;
            }
        },

  3. #3
    Sencha User vishalnnsingh's Avatar
    Join Date
    Sep 2010
    Location
    Kolkata, India
    Posts
    115

    Default

    Thanks this worked for me.....
    I had a formapanel inside a pop up window which contained multiselect,this.view is undefined error was killing me and the window too was not defined.
    I Meet Challenge with Excitement & My Only Gossip is Love

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •