Announcement

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

    form.getValues() returns formatted value when using formatValue and formatOnBlur

    SmartClient Version: v10.0p_2014-11-16/EVAL Development Only (expires 2015.01.15_12.11.41) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

    Chrome on OSX

    please modify the #formatRelatedValue sample like this:

    Code:
    isc.DynamicForm.create({
        ID:"testForm",
        items : [
            { name:"otherEmployeeName", title:"Employee", type: "comboBox",
              optionDataSource:"employees", 
              valueField:"EmployeeId", displayField:"Name",
              pickListFields:[
                  {name:"Name"},
                  {name:"Email"}
              ],
              width:250, pickListWidth:350,
              formatOnBlur: true,
              formatValue : function (value, record, form, item) {
                  var selectedRecord = item.getSelectedRecord();
                  if (selectedRecord != null) {
                     return selectedRecord.Name + " (" + selectedRecord.Email + ")";
                  } else {
                     return value;
                  }
              }
            }
        ]
    });
    Please select an option, then press tab to have it formatted.
    Now, if you evaluate testForm.getValues() you'll obtain something like
    {otherEmployeeName: "Tamara Kane (tkane@server.com)"}

    instead of the correct {otherEmployeeName: 182} which you obtain when not formatted.

    #2
    Thanks for the report - this has been fixed in latest builds.

    Comment


      #3
      SmartClient Version: v10.0p_2014-12-04/EVAL Development Only (expires 2015.02.02_10.52.03) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

      Strange....it's fixed if I click outside to have it formatted...

      if, instead, I press the tab key to trigger the formatOnBlur, the bug is still there: getValues() returns the formatted value.

      (edited to clarify - sorry for my bad English)
      Last edited by claudiobosticco; 18 Dec 2014, 01:32.

      Comment


        #4
        SmartClient Version: v10.0p_2015-01-14/EVAL Development Only (expires 2015.03.15_10.24.32) Licensed to: Isomorphic Software (#ISC_EVAL_NIGHTLY)

        this problem is still there.

        Comment


          #5
          I have the same issue, is this fixed in the mean time?

          Comment


            #6
            No, not yet - it's queued to be looked at.

            Comment


              #7
              Thanks for your response. I've investigated it a bit and it's a difficult one to solve. The issue is with mapping the displayValue to the datavalue. This function (mapDisplayToValue) uses the displayField to resolve the datavalue from the cached recordset. The formatted value does not equal the displayvalue, thus the only solution would be to format each cached record and compare the result with the formatted value, but this would be very inefficient.

              Anyway, I made a quick and dirty solution, use at own risk:
              Code:
              isc.MyComboBoxItem.addProperties({
                  mapDisplayToValue: function (value, a, b, c) {
                      var result = this.Super('mapDisplayToValue',arguments);
                      if(isc.isA.String(result) && this.lastFormattedValue == result){
              		result = this.getValue();
              	}
              	return result;
                  },
                  formatValue: function(value,record,form,item){
                       var formattedValue = value; 
                       // Format the value here
                       item.lastFormattedValue = formattedValue ; 
                       return formattedValue; 
                  }
              })

              Comment

              Working...
              X