Announcement

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

    Possible Bug in ComboBoxItem with fetchDisplayedFieldsOnly=true

    Hello,

    SmartClient Version 9.1 Pro (and also debugged in LGPL)

    As per docu, ComboBoxItem can be configured to set fetchDisplayedFieldsOnly = true, so the list of fields used by this pickList will be passed to the datasource as DSRequest.outputs.

    Per docu pickListFields should be specified as an array of ListGridField.

    However, the code that build the value for DSRequest.outputs does not consider to extract the field name from a ListGridField object.

    Please see PickList.js method makePickList : function()

    Code:
     // If limiting the fetch fields, build the correct optionFilterContext.outputs
            if (this.fetchDisplayedFieldsOnly && this.optionDataSource &&
                (!this.optionFilterContext || !this.optionFilterContext.outputs))
            {
                var fields = this.pickListFields || [];
                if (this.valueField) fields.add(this.valueField);
                if (this.displayField) fields.add(this.displayField);
                if (fields.length > 0) {
                    if (!this.optionFilterContext) this.optionFilterContext = {};
                    this.optionFilterContext.outputs = fields.getUniqueItems().join(',');
                }
            }
    The resulting output as reported in the dev console is e.g.:
    outputs:"[object Object],[object Object],[object Object],Sku"
    Where Sku is added fom this.valueField.

    Please have a look.

    Best regards,
    Daniel

    #2
    Thanks for your report, we have fixed the bug, it will be available in the next nightly build, dated May 14th.

    Comment


      #3
      Related to this issue, I think there's undesired behavior where the original list of pick list fields is extended with the name of the valueField and displayField (if specified) because fields is a reference to this.pickListFields.

      I've just enabled the fetchDisplayedFieldsOnly and I got an error in one of my own components. It turns out this error occured because instead of a field object I have two extra pick list fields "id" and "name" (which in my case were the valueField and displayField.

      I'm not sure, but I would think that the name of the valueField and displayField are only needed in the outputs string.

      Tested on the January 31st, 2016 version of SmartClient 10.1 Pro.

      Comment


        #4
        Sorry, can you clarify that? The idField at the least is needed to identify records - are you saying that the idField ends up displayed even when it has been omitted from pickListFields? We're not seeing that issue, can you show how to reproduce it?

        Comment


          #5
          This particular piece of code in PickList.js, lines 1443-1449 (SmartClient_v101p_2016-02-03_LGPL) ...

          Code:
          // If limiting the fetch fields, build the correct optionFilterContext.outputs
          if (this.fetchDisplayedFieldsOnly && this.optionDataSource &&
              (!this.optionFilterContext || !this.optionFilterContext.outputs))
          {
            var fields = this.pickListFields || [];
            if (this.valueField) fields.add(this.valueField);
            if (this.displayField) fields.add(this.displayField);
          ... causes this.pickListFields to be extended (because fields is a reference to this.pickListFields and not a copy) with one or two extra fields in case this.valueField and/or this.idField are defined (and not already in the field list). I don't think this is correct. I would think the desired behavior is to have the server send back all displayed fields AND - if not shown - the idField and valueField.

          I noticed this accidentally when iterating over this.pickListFields and assuming that each member was an object, but got an error because two members where simply strings. Those were added by the code above.

          I hope this clarifies my point.

          Comment


            #6
            Specifying fields as just a String is a valid (internal) usage. Let us know if you have a minimal test case that demonstrates a framework issue - very often inspecting code can lead to speculations about possible bugs that aren't actually issues in practice.

            Comment


              #7
              I actually hoped my earlier post was descriptive enough. :-)
              Before giving a minimal test case, let me rephrase the question again.

              Is it desired that the number of pick list fields (as defined in pickListFields) changes when fetchDisplayedFieldsOnly is set to true and idField and/or valueField are defined but not in pickListFields?

              I would say this is an unwanted side effect.

              Comment


                #8
                The number of *visible* fields should not change if pickListFields has been explicitly specified. It would be normal for those fields to be added, but not end up visible in the pickList.

                If you are seeing additional *visible* fields in the pickList that you did not specify, that sounds like a bug, but again, a test case is needed.

                Comment

                Working...
                X