How to use GoJS DataInspector to add custom values

I have an array of choices maintained independently to use commonly in all diagram nodes.

var customVariables = ["select","Add new"];

If someone selects the “Add new” option from any drop-down that user can add another option to this array and it needed to display in all dropdowns immediately. for this, I edited the DataInspector.js file ‘buildPropertyRow’ method. so that I can prompt a input and push the data to the array. screenshots as follows.


ss2

But the issue is after the insertion, the code will call updateAllProperties() method and all inputs will be updated. but in this state select option still have the value Add new even after I set it to the newly added value. I need to change this behaviour. To do that I used setDataProperty method after new data has been added. but now it duplicates inputs in the inspector view as in the picture.

I go through a lot of articles and seems to have a solution if I use addArrayItem or insertArrayItem. but there is no example of how to use these methods and still not sure this will help me with my problem as well.

so are these methods gonner help me or how do I overcome this issue are my questions.

After the user has OK’ed some new text, what is the value of customVariables? Did you replace the value of customVariables to refer to a new Array, or did you modify the existing Array?

How does your template define the TextBlock for which you have set or bound TextBlock.choices?

I use the javascript push method to push added data to the array.

customVariables.push(newVariables)

so user add text saying test, values will be

var customVariables = ["select","Add new","test"];

that part is working fine. and also the duplicate dropdown comes with that added data. the only issue is that inputs duplicating.

Normally one must call Model.addArrayItem if you want to modify an Array that is in some model data. But that does not seem to be the problem here.

Hmmm, so it seems to be a bug in your custom inspector. I would debug it by stepping through the code that constructs the HTML.