B4J Question [BANano] SetField & SetAttr using JSON

Mashiane

Expert
Licensed User
Hi there

Whilst SetStyle is able to receive a JSON value to apply the styles to it. Is it possible to implement similar for .SetField and .SetAttr so that they receive a JSON string / Map Object.

This can greatly help in setting up multiple fields and multiple attributes at the same time.

For example...

B4X:
Dim canvas1 As BANanoElement = body.Append($"<canvas id="mycanvas"><canvas>"$).Get("#mycanvas")
    canvas1.SetAttr("width","600")
    canvas1.SetAttr("height","400")
    canvas1.SetText("Your browser does not support the HTML 5 Canvas.")
    canvas1.SetStyle(BANano.ToJson(CreateMap("border":"1px solid black")))
It could be

B4X:
canvas.SetAttr1(BANano.ToJSON(CreateMap("width":"600","height":"400))))
Ta!
 
Top