Hello,
My data contains a list, which I would like to be user-editable, but I am failing to make the two-way binding work. E.g. the data for a node looks this:
{ "text":"hello", "list":[1,2,3] }
I am displaying such a node like this:
$(go.Node, "Auto", $(go.Shape, "Rectangle"),
$(go.Panel, "Vertical",
$(go.TextBlock, new go.Binding("text","text")),
$(go.Panel, "Table", new go.Binding("itemArray","list"),
{ itemTemplate: $(go.TextBlock, new go.Binding("text","").makeTwoWay(), {editable:true}) }
)
)
)
-----------
| hello |
| 1 |
| 2 |
| 3 |
-----------
The user editing any item 1,2,3
in the list does not update the model. I see from Binding | GoJS API that
Because in this example the source property name is the empty string, and because one cannot replace the whole source data object, any return value from the conversion function is ignored.
I see from e.g. Binding to structured node data that there is sometimes a way to bind the data anyway, using a backConverter
. I tried passing such a function, bC
, to .makeTwoWay(bC)
:
function bC(target,dataobj) {
dataobj = target
}
This (probably as expected …) has no effect. It seems that target
is just the new value and dataobj
the old value.
How can you make the two-way binding work for elements of an array?
Thanks,