Announcement

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

    FormItem with comboBox-type ignores selectOnClick

    Hi there,
    I'm using a TextItem with the combobox-editorType.
    Using a datasource there seems something wrong, that the text is not seleted even though selectOnClick is set to true



    Ite reproducable with the latest build: SmartClient_v110p_2017-05-22_Pro.
    Also it is reproducable with all current browsers.

    Code:
    Code:
    isc.DynamicForm.create({
        "ID": "theForm",
        "width": "100%",
        "fields":
        [{
                "ID": "theReferenceTextItem",
                "name": "theReferenceTextItem",
                "title": "Reference",
                "type": "text",
    
                "selectOnClick": true
            }, {
                "ID": "theComboBoxItem",
                "name": "theComboBoxItem",
                "title": "Test",
                "type": "text",
                "editorType": "comboBox",
                "selectOnClick": true,
                "fetchDelay": 500,
                "textMatchStyle": "substring",
                "allowEmptyValue": true,
                "displayField": "capital",
                "valueField": "countryName",
                optionDataSource: isc.DataSource.create({
                    "fields":
                    [{
                            "name": "countryName",
                            "type": "text"
                        }, {
                            "name": "countryCode",
                            "type": "text"
                        }, {
                            "name": "capital",
                            "type": "text"
                        }
                    ],
                    "dataFormat": "json",
                    "useHttpProxy": false,
                    "dataURL": "http://www.smartclient.com/docs/10.0/a/system/reference/inlineExamples/grids/data/countryData.json",
                    "recordXPath": "/",
                    "cacheData":
                    [{
                            "number": "",
                            "countryName": "",
                            "countryCode": "Keine",
                            "capital": "Keine"
                        }
                    ]
                })
    
            }
        ],
        "values": {
            "theComboBoxItem": "",
            "theReferenceTextItem": "test"
        }
    });
    Kind regards

    #2
    You want editorType: "ComboBoxItem"

    Comment


      #3
      Thanks, but same result, as showed in the first post.

      Comment


        #4
        In this case, you just need to set your initial value for theTextBoxItem to null, rather than "" - we'll look at whether a framework change is necessary:

        Code:
            ...
            "values": {
                "theComboBoxItem": null,
                "theReferenceTextItem": "test"
            }

        Comment


          #5
          Thanks for the workaround, but setting null as a value removes the text from the combobox completely. (Tested with SmartClient_v110p_2017-05-26_Pro)


          I think this should be handled in the framework, so the described behaviour in the doumentation is correct and the user can select the text with one click.

          Best regards

          Comment


            #6
            What are you actually trying to do? Your DS has no PK adn the value you're trying to apply is "", which wouldn't be a valid identifier anyway.

            Comment


              #7
              The target I want to accomplish is shown in the first image. I want that the ComboBox does show the cached data so the combobox does not execute a datasource-request to the server if the user does not click into it. If a user clicks on the lower textItem the text should be marked (like in the first row).

              Not listing the Item in the values-object does the same as set it to null => the value I want to display does not show up.
              With an empty string the string "None" shows up, but the selectOnClick-property gets ignored.
              So my assumption is that there is some inconsistency if the textitem does show text but the selectOnClick gets ignored.

              Comment


                #8
                Right - you need to give your dummy DS a primaryKey field, and have the cacheData entry use a valid identifier - that is, not "".

                For example, countryName: "__default", which you then apply toboth the DS and the values clause

                For clarity, allowEmptyValue doesn't do anything in this case, if that's what you're expecting - indeed, by default, it doesn't do anything, because addUnknownValues is true by default. See the doc for allowEmptyValue, if that's not clear.
                Last edited by Isomorphic; 29 May 2017, 02:25.

                Comment


                  #9
                  You are right, and in the example I may have described it as good as possible.
                  In our application there is a Combobox with user gernerated items. There is a numberField, nameField and a nameAndNumberField which is used as displayValue. Also the numberField is our primary-key.
                  All names and numbers of the user-generated objects, that are displayed in the ComboBox have to be not empty.
                  We must also present a "None"-object, which also represents an object at the backend, which can be saved.
                  Because every element in the Combobox is user generated, the only "valid" value we can use to add the "None"-object ist the value "empty-string", because none of the user generated values can have this value.

                  Code:
                  ...
                  "textMatchStyle": "substring",
                  "displayField": "nameAndNumberField",
                  "valueField": "numberField",
                  optionDataSource: isc.DataSource.create({
                      "fields":
                      [{
                              "name": "numberField",
                              "type": "text"
                          }, {
                              "name": "nameField",
                              "type": "text"
                          }, {
                              "name": "nameAndNumberField",
                              "type": "text"
                          }
                      ],
                  ...
                  It's true, that when setting a value into the numberField of the "None"-object, it works, but we cannot use this because every string could be a value of a user-generated number of their defined objets.

                  So the given "empty string" in the values represents the correct value of the selected object. I also haven't found a reference in the documentation that an empty key is forbidden.
                  I assume this is a special case, but the combobox is indeed working correct, except the selectOnClick-variable. This seems to handle an empty value not correct and does not lookup the display-value in the cache of the datasource.

                  Best regards

                  Comment


                    #10
                    Neither of your code extracts specify a primaryKey: true field and you need one.

                    Once you've done that, if the field you choose is a number field and you set that to comboBoxItem.valueField, then values processed by the ComboBoxItem are always going to be numbers, or null - not strings, so not "".

                    You could use -9999, or similar, as the pk for an entry that represents your blank entry.

                    However - you should probably just fix your primaryKey field and then not bother setting cacheData at all - instead just set item.emptyDisplayValue: "Keine" and apply null in your form's values clause.

                    At that point, you will find that selection still doesn't work - however, we've just fixed that bug, and you can test the fix in builds dated June 2 and later.

                    Comment

                    Working...
                    X