Select to view content in your preferred language

Assigning a field "codedValues" for the editor widget

661
1
Jump to solution
10-07-2022 07:49 AM
AndrewMurdoch1
Frequent Contributor

Good Day

I have a field visible in the editor to change how a featured is rendered, but the field itself is a string value.  Is it possible / how do It pass, codedValues in the editor config, so the input is a drop down?

if (event.added.length > 0) {
    this._editWidgetConfiguration = [];
    this._view.map.layers.forEach((layer) => {
       this._editWidgetConfiguration.push({
           layer: layer,
           formTemplate: {
               elements: [{
                   type: "field",
                   fieldName: "layer",
                   label: "blah",
                   codedValues: [
                       {name: "1", code: "1"},
                       {name: "2", code: "2"},
                   ]
               }]
            }
        })
    });

    console.log('Edit Widget Configuration');
    console.log(_.cloneDeep(this._editWidgetConfiguration));

    this.editorWidget.layerInfos = this._editWidgetConfiguration;
}


That code is ran when layers are added to the map.  I have the list of available settings available at this point, because I've built the unqiue render settings, so how do I pass the coded values to the editor?

The field is defined as:

{
    name: 'layer',
    alias: 'layer',
    type: 'string'
},


Thanks

0 Kudos
1 Solution

Accepted Solutions
AndrewMurdoch1
Frequent Contributor

Figured out the problem, you have to tell the setting it's a coded-value domain, the following code works:

this._editWidgetConfiguration.push({
    layer: layer,
    formTemplate: {
        elements: [{
            type: "field",
            fieldName: "layer",
            label: "blah",
            domain: {
                codedValues: [
                    {name: "1", code: "1"},
                    {name: "2", code: "2"},
                ],
                type: 'coded-value'
            }
        }]
    }
})


Hopefully this helps someone else 🙂


Thanks

View solution in original post

1 Reply
AndrewMurdoch1
Frequent Contributor

Figured out the problem, you have to tell the setting it's a coded-value domain, the following code works:

this._editWidgetConfiguration.push({
    layer: layer,
    formTemplate: {
        elements: [{
            type: "field",
            fieldName: "layer",
            label: "blah",
            domain: {
                codedValues: [
                    {name: "1", code: "1"},
                    {name: "2", code: "2"},
                ],
                type: 'coded-value'
            }
        }]
    }
})


Hopefully this helps someone else 🙂


Thanks