Announcement

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

    ComboBoxItem getSelectedRecord possible bug

    In the latest eval builds it seems there's a problem with ComboBoxItem.getSelectedRecord.

    It always returns null

    Tested with: SC_SNAPSHOT-2010-03-28

    With an older build, like SC_SNAPSHOT-2010-03-10/EVAL it's working OK.

    Also the Devel consoles issues the following warning:
    Code:
    13:48:42.213:MUP9:WARN:ComboBoxItem:isc_ComboBoxItem_0:$751 is null but the item has a value: "US"
    
    setting $751 to the record associated with the current _value:
    null
    Test case attached
    Attached Files

    #2
    Thanks - this was a temporary regression that was fixed this morning, pick it up in tonight's nightly.

    Comment


      #3
      Are you sure this fix has been committed? It seems the problem still exists in 29 & 30th release...

      Comment


        #4
        You needed to grab a new nightly eval of Pro/EE, although it's now hit SVN as well.

        Comment


          #5
          Hey guys,

          Sorry for bringing this up again, but either I'm using this control the wrong way, or you missed something here :)

          having the following code:
          Code:
              DynamicForm df = new DynamicForm();
              final ComboBoxItem comboBoxItem = new ComboBoxItem("countryId", "Country Id");
              comboBoxItem.setOptionDataSource(CountryLocalDS.getInstance());
              df.setFields(comboBoxItem);
              
              IButton testButton = new IButton("Test");
              testButton.addClickHandler(new ClickHandler() {
          
                public void onClick(ClickEvent event) {
                  Window.alert("Selected record: " + comboBoxItem.getSelectedRecord());
                }
              });
              df.draw();
              testButton.setLeft(200);
              testButton.draw();
          When I select smth from the ComboBox and click Test a messagebox should pop-up with the toString version of the currently selected record. Right?

          Well in the 2.1 official LGPL release everything is as expected.
          In the 2.2 LGPL the output is "null"

          Same for EVAL versions... (also tried the latest nightly builds).

          In the first post you have a copy-pastable standalone test case.

          Please let me know if I'm doing something wrong, or it is indeed a problem here. Thanks.

          Comment


            #6
            Hi
            We double checked on this and there is indeed a bug.
            You can workaround this by explicitly specifying a value field for your item:
            Code:
                final ComboBoxItem comboBoxItem = new ComboBoxItem("countryId", "Country Id");
                comboBoxItem.setValueField("countryId");
                ...
            We'll get this fixed in the near future
            Thanks
            Isomorphic Software

            Comment


              #7
              Hi,

              I was just wondering if you got this working?
              I was using the same code and since reading this have added the comboBoxItem.setValueField("customerName") but still get a null value when using comboBoxItem.getSelectedRecord()

              Many Thanks

              Comment


                #8
                Well, I'm still using an older build.

                @Isomorphic. I've just tried one of the latest nightly and you partially fixed the problem :)

                On selection change it returns ONLY the first record, no matter what I choose.

                Comment


                  #9
                  Ah, I have now reached the same point as you!
                  I also now get a record back when calling getSelectedRecord but as you it is always the same (first) record.

                  Is this a bug? - No, its not. It is all working for me now. Not sure exactly what I changed but now on selection the correct record is being fetched.

                  Cheers
                  Last edited by jrich; 7 Jun 2010, 12:43.

                  Comment


                    #10
                    jrich, Could you post the last version (that works). I'd like to compare with what I have and see what I've missed :)

                    Comment


                      #11
                      sure, the file is attached.

                      It is a bit long winded at the moment, I wanted to get all fields available for selection and then fill remaining fields from which ever selection was made.

                      Will come back to it at some point, but at the moment it works!

                      Have attached the file
                      Attached Files

                      Comment


                        #12
                        Thanks. My code looks ok.

                        Strange enough this doesn't seem to work for me. The only way I could get it working is by using the fix from this post:

                        http://forums.smartclient.com/showpo...70&postcount=2

                        Code:
                                final ComboBoxItem editor = new ComboBoxItem() {
                                    public native ListGridRecord getSelectedRecord() /*-{
                            	    
                            	    var self = this.@com.smartgwt.client.core.DataClass::getJsObj()();
                            	    var ret = self.pickList.getSelectedRecord();   	    
                            	    if(ret == null || ret === undefined) return null;
                            	    var retVal = @com.smartgwt.client.core.RefDataClass::getRef(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
                            	    if(retVal == null) {
                            	        retVal = @com.smartgwt.client.widgets.grid.ListGridRecord::new(Lcom/google/gwt/core/client/JavaScriptObject;)(ret);
                            	    }
                            	    return retVal;
                            	}-*/; 
                              }
                        Thanks elvisv8 for posting this ;)

                        Comment


                          #13
                          In the current LGPL-SC builds, there is still a bug: just try

                          Code:
                          isc.DynamicForm.create({
                              width: 500,
                              numCols: 4,
                              fields : [{ ID: "foo",
                                  name: "itemName", title: "Item Name", editorType: "comboBox",
                                          completeOnTab: true,
                                          blur: function(form, item) {
                                              console.log(item.getSelectedRecord() == null ? null : item.getSelectedRecord().itemID);
                                          },
                                  optionDataSource: "supplyItem", pickListWidth: 250
                              }]
                          });
                          within the showcase. After selecting the first record, null is being returned. After selecting another record, the selected record is being returned. Each subsequent selection of other records does not change the result of getSelectedRecord(), it will always return the second selected result.

                          Comment


                            #14
                            I found that while calling item.getSelectedRecord() returns inconsistent results, calling item.pickList.getSelectedRecord() produces more or less what I expect (hopefully this API will be stable)... I have to admit that this solution was already present in the SmartGWT code some posts above (http://forums.smartclient.com/showpo...7&postcount=12) - I just did not see it.
                            Last edited by ect; 24 Jun 2010, 04:00.

                            Comment


                              #15
                              Diferent problem in nightly build "2010-07-07"

                              when calling item.getSelectedRecord() for the first time it works fine.

                              If the user changes the value of the comboboxitem and you call item.getSelectedRecord() again it does not change the selectedRecord. It is returning the first item selected

                              Comment

                              Working...
                              X