Select to view content in your preferred language

Adding new objects-array config element that will look nice, both in "Content" tab and in application config

157
1
Jump to solution
4 weeks ago
Labels (2)
MichaelLev
Regular Contributor

I adapted arcgis-map widget to make it one of my custom widgets.

In the development ide, in arcgis-map "Content" tab (which is handled by setting.tsx), I added a new config element, which is a json array of objects, so in the text area I write it:
[
    {
        "param1": "string1-1",
        "param2":"string1-2",
        "param3":250},
    {
        "param1": "string2-1",
         "param2": "string2-1",
         "param3":100
    }
]

 

I managed that it will work well, but there is an "ugliness" problem:
When I create and expand the zip file, then:

 

In the application config it appears as if it is a string:
"newElement": "[\n  {\n    \"param1\": \"string1-1\",\n    \"param2\": \"string1-2\",\n    \"param3\": 10\n },\n   {\n    \"param1\": \"string2-1\",\n    \"param2\": \"string2-2\",\n    \"param3\": 200\n  }\n]"

 

But I prefer that the new config element will appear in the application config as an array of objects:
"newElement": [
    {
        "param1": "string1-1",
        "param2":"string1-2",
        "param3":250},
    {
        "param1": "string2-1",
         "param2": "string2-1",
         "param3":100
    }
]

 

To sum up in other words - I need that the text-area in "Content" tab will refer it as a string,
while in the created zip and hence in the application config file, it will be referred as an array of objects

0 Kudos
1 Solution

Accepted Solutions
MichaelLev
Regular Contributor

I solved it.
The new config element type if array of objects.

Only in setting.tsx in render(),
I do JSON.stringify(element, null, 2) in order to display it nicely in the TextArea in "Content" tab

View solution in original post

0 Kudos
1 Reply
MichaelLev
Regular Contributor

I solved it.
The new config element type if array of objects.

Only in setting.tsx in render(),
I do JSON.stringify(element, null, 2) in order to display it nicely in the TextArea in "Content" tab

0 Kudos