Announcement

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

    editorValueMap not being utilized for editing listGridField

    Hi, please let me know if I am doing something wrong here but it looks like the editorValueMap is not being used for editing a list grid field. Use the code below and when you click ont he continent field there is no value map displayed even though we configured an editorValueMap


    Use this example here: https://www.smartclient.com/smartclient-release/showcase/?id=listType



    Code:
    isc.ListGrid.create({
        ID: "countryList",
        width:500, height:224, alternateRecordStyles:true, 
        canEdit:true, editEvent:"click", modalEditing:true,
        data: countryData,
        fields:[
            {name:"countryCode", title:"Flag", width:50, type:"image", imageURLPrefix:"flags/16/", imageURLSuffix:".png", canEdit:false},
            {name:"countryName", title:"Country"},
            {name:"continent", title:"Continent",
                editorValueMap:["Europe", "Asia", "North America", "Australia/Oceania", "South America", "Africa"]
            }
        ]
    })
    Code:
    [URL="https://www.smartclient.com/smartclient-release/showcase/?id=listType"][/URL]

    #2
    Actually, I found the issue and produced a patch. Looks like you aren't checking properly for editorValueMap in this method:

    Code:
        //patch to check for editorValueMap
        if (window.isc &&  (isc.version.startsWith("v12.0")    )){
    
             isc.DynamicForm.addClassProperties({
    
                 getEditorType: function (_1, _2, _3) {
                     if (_1._constructor == isc.FormItem.Class) _1._constructor = null;
                     var _4 = _2.getDataSource();
                     var _5 = this.canEditField(_1, _2),
                         _6 = this.defaultFieldType,
                         _7 = _1.editorType;
                     if (isc.isA.Class(_7)) {
                         _7 = _7.getClassName()
                     }
                     if (_7 == this.$178h) _7 = null;
                     var _8 = !_1.editNode || isc[_1._constructor];
                     var _9 = (_5 == false && _1.readOnlyEditorType) || _7 || _1.formItemType || (_8 && _1._constructor);
                     if (_9 == null) {
                         _9 = _2 && _2.getFieldType ? _2.getFieldType(_1, _3) : _1.type
                     }
                     if (_9 == null) _9 = _6;
                     if ((_5 == false && _1.readOnlyEditorType) || _7 || _1.formItemType || _1._constructor) {
                         return _9
                     }
                     var _10 = _9;
                     var _11 = null;
                     var _12 = (_9 == this.$12e || _9 == this.$52x || _9 == this.$677);
                     while (_10) {
                         if (_9 == this.$12a) {
                             if (this.canEditField(_1, _2) && _1.canEdit) _11 = this.$gx;
                             else _11 = this.$12a
                         } else if (_9 == this.$g2) {
                             var _13 = _1.valueMap;
                             if (!isc.isAn.Array(_13) && isc.isAn.Object(_13)) _11 = this.$12b;
                             else _11 = this.$12c
                         } else if (_9 == this.$12e || _9 == this.$12f || _9 == this.$52x || _9 == this.$677) {
                             if (_1.dataSource) _11 = this.$52w
                             else _11 = this.$52x
                         } else if (_9 == this.$12g) {
                             _11 = this.$52w
                         } else if (_9 == this.$51x) {
                             _11 = this.$51x
                         } else if (_9 == this.$12h) {
                             if (_1.showValueIconOnly) _11 = this.$12i
                             else _11 = this.$12b
                         } else if (isc.DataSource && isc.isA.DataSource(_4) && _4.fieldIsComplexType(_1.name)) {
                             _11 = _1.multiple ? _2.nestedListEditorType : _2.nestedEditorType
                         } else {
                             if (_10 && _10 != _6 && _10 != this.$gz && (_10 == this.$12j || (isc.FormItemFactory.getItemClass(_10) != null))) {
                                 _11 = _10
                             } else {
                                 _10 = isc.SimpleType.getType(_10);
                                 if (_11) {
                                     break
                                 } else if (_10 == null || _10.inheritsFrom == null) {
                                     if (_1.dataSource) {
                                         _11 = this.$12k
                                     //patch to check for editorValueMap too
                                     } else if (_1.editorValueMap || _1.valueMap || _1.optionDataSource || _1.displayField) {
                                         _11 = (_1.showValueIconOnly ? this.$12i : this.$12b)
                                     } else if (_2 && (_1.length && _1.length > _2.longTextEditorThreshold)) {
                                         _11 = _2.longTextEditorType
                                     } else {
                                         _11 = _6
                                     }
                                 } else {
                                     _10 = _10.inheritsFrom;
                                     _9 = _10;
                                     _11 = null;
                                     continue
                                 }
                             }
                         }
                         break
                     }
                     return _11
                 }
    
             })
        }

    Comment


      #3
      editorValueMap really exists so that the editor's valueMap can differ from the field's normal valueMap.

      So just to verify here - you have a field for which you do not want a valueMap (so the raw values will appear), but you do want editing to take place via a valueMap (hence a SelectItem)?

      That seems a little odd - it seems like you would just specify valueMap and not specify editorValueMap, and that's just simpler.

      Is there some reason why you need to avoid specifying valueMap here?

      Note that, if you have some very good reason for specifying editorValueMap but not valueMap, it looks like the only thing you wanted out of your editorValueMap setting was that a SelectItem would be chosen for editing, right? But that can be done by just specifying editorType:"SelectItem".

      Comment


        #4
        Yes, we don't want to utilize a valueMap in display mode because the valueMap is messing up the formatting we are trying to apply in formatCellValue. We only want to utilize a valueMap in edit mode so the user is forced to pick an option from a list thus we only want to define an editorValueMap. You are right we can just use editorType:"SelectItem" and that works for us. Thanks for the suggestion. So, we will remove the patch and use that approach. However, based on the way your docs describe editorValueMap, I think you should consider applying the patch I provided to handle this use case because you should be able to define an editorValueMap without defining a valueMap.

        Comment

        Working...
        X