Announcement

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

    Databound SelectItem with multiple values

    I'm using SmartClient 8 (2011-01-05).
    On a DynamicForm with a databound SelectItem
    Code:
    {
       name : "classification1",
       titleAlign : "left",
       width : "*",
       required : true,
       editorType : "select",
       multiple : true,
       autoFetchData: false
    },
    we have a problem with the datatype sent back to the server in case of a update request.
    In version 7 the client has sent a list if the user has selected multiple values.
    With version 8 the client sends a string with the comma-separated values (e.g. "value1,value2").
    Even if the 'previous values' part of the same request still holds a list for this item (e.g. ["value1","value2"].

    I will submit the complete Request-XML, the problem is with field 'classification1'
    Attached Files

    #2
    We don't really have a specific format in which we send arrays of Strings, but you can define one via transformRequest().

    Comment


      #3
      Adding code to datasource.transformRequest is not very helpfull as the value is allready a concatenated string there.

      And there is another Problem:
      The SelectItem has a value map. It correctly displays multiple values delivered as List<String> from the backend.
      After an update its value is a concatenated String (of the keys). This cannot be displayed correctly by the same
      SelectItem as there is no value map entry for such a concatenates String.
      Last edited by brunostuder; 1 Feb 2011, 01:33.

      Comment


        #4
        Both problems indicate that you've got the field declared as type:"text" but have not set multiple:true.

        Comment


          #5
          The form-field is declared as multiple=true as written in my first post.
          The datasource is also declared as multiple=true like this

          Code:
          {
            name : "classification1",
            title : msg.texts.trainingClassification1,
            type : "text",
            multiple : true
          },

          Comment


            #6
            This definitely works with the latest (value arrives at transformRequest() as an Array). Please try it out.

            Comment


              #7
              I have added this code to my DataSource
              Code:
                       transformRequest : function(dsRequest)
                       {
                          if (dsRequest.operationType == "update" || dsRequest.operationType == "add") {
                             var field = dsRequest.data.classification1;
                             if (isc.isA.Array(field)) {
                                this.logWarn("field is Array", "masoft");
                             } else if (isc.isA.List(field)) {
                                this.logWarn("field is a List", "masoft");
                             } else if (isc.isA.String(field)) {
                                this.logWarn("field is String", "masoft");
                                this.logWarn("my value is |" + field + "|");
                                this.logWarn("i'm multiple " + this.getField("classification1").multiple);
                             } else {
                                this.logWarn("field is something else", "masoft");
                             }
                          }
                          return this.Super("transformRequest", dsRequest);
                       }
              This is the log
              Code:
              14:34:28.625:MUP2:WARN:masoft:Training$TrainingSpecifications:field is String
              14:34:28.625:MUP2:WARN:msgDataSource:Training$TrainingSpecifications:my value is |xri://@openmdx*org.opencrx.kernel.product1/provider/MASOFT/segment/Afc/productClassification/RI0BXYX4TXASG0RPCRXDWWFWQ,xri://@openmdx*org.opencrx.kernel.product1/provider/MASOFT/segment/Afc/productClassification/RI0BXYP8PH2W00RPCRXDWWFWQ|
              14:34:28.626:MUP2:WARN:msgDataSource:Training$TrainingSpecifications:i'm multiple true

              Comment

              Working...
              X