Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ComboBox Default Value Issue

    SmartClient Version: SNAPSHOT_v9.0d_2012-11-15/PowerEdition Deployment (built 2012-11-15)

    Before I post any code I wanted to know if you may have an explanation for this behavior I'm seeing with the ComboBoxItem widget.

    I believe my code is vanilla, we have many instance of ComboBoxItems sprinkled around our code base and all others work, and this one is coded similarly.

    This ComboBoxItem has an attached option DataSource.

    Clicking inside the box causes the dropdown list to populate with a list of names of files from a simple DataSource.

    However one of the 10 returned records (the file names) had a value 'Default'. The box always selected that value, but the getValue() call on the box always returned a null string. The box would display the string 'Default'.

    I failed to change this behavior having tried to setDefaultValue() and as many option variations as I could find.

    Eventually I simply removed the record from the database that contained the 'Default' file name. No code changes.

    The ComboBoxItem now works flawlessly. I can select items from the dropdown and tab and arrow key between choices and override the choices.

    I suppose I should go back and add the data record back in and see if the ComboxBox goes back to the failing state.

    Are you aware of any such issues?

    --> Please ignore this part of the post. The ComboBox is just selecting the first record in the dropdown list. Deleting the 'Default' record just moved the selection to the next in the list.
    Last edited by tece321; 14 Jan 2013, 15:16. Reason: Underlying issue is ComboBox is only selecting FIRST item from dropdown list!

    #2
    This piece of code fails to select from the dropdown list:

    Code:
    ComboBoxItem  waiverName = new ComboBoxItem("Waiver_Name", "Save Waiver As");
    
    waiverName.setRequired(true);
    waiverName.setWidth(300);	
    
    waiverName.setSortField("NameOfWaiverSet");	
    waiverName.setDisplayField("NameOfWaiverSet")
    waiverName.setValueField("WaiverOfWaiverSet");
    DataSource waiverNameCBDS = DataSource.get("BCG_WaiverSetDropdown");
    		waiverName.setOptionDataSource(waiverNameCBDS);
    waiverName.setDefaultToFirstOption(false);

    This code works, the ComboBoxItem does the correct selection:

    Code:
    ComboBoxItem  waiverName = new ComboBoxItem("NameOfWaiverSet", "Save Waiver As");
    		
    waiverName.setRequired(true);
    waiverName.setWidth(300);	
    waiverName.setSortField("NameOfWaiverSet");	
    DataSource waiverNameCBDS = DataSource.get("BCG_WaiverSetDropdown");
    		waiverName.setOptionDataSource(waiverNameCBDS);
    waiverName.setDefaultToFirstOption(false);

    What is wrong with the first code segment?

    Comment


      #3
      Way too little information to say, but, perhaps a difference in the actual data delivered, such as the ValueField not being unique or being missing for some records.

      Comment


        #4
        [QUOTE=tece321;97913]This piece of code fails to select from the dropdown list:

        Code:
        ComboBoxItem  waiverName = new ComboBoxItem("Waiver_Name", "Save Waiver As");
        
        waiverName.setRequired(true);
        waiverName.setWidth(300);	
        
        waiverName.setSortField("NameOfWaiverSet");	
        waiverName.setDisplayField("NameOfWaiverSet")
        
        +++++++++++++++++++++++++++++++++++
        waiverName.setValueField("WaiverOfWaiverSet");
        +++++++++++++++++++++++++++++++++++++
        
        DataSource waiverNameCBDS = DataSource.get("BCG_WaiverSetDropdown");
        		waiverName.setOptionDataSource(waiverNameCBDS);
        waiverName.setDefaultToFirstOption(false);
        Of course looking at this code in this window the error pops right out for me. The above code line should have been:

        Code:
        waiverName.setValueField("NameOfWaiverSet");

        Comment


          #5
          OK, good to know it's now working as expected.

          Comment

          Working...
          X