I’m trying to send a jsonitem to the browser, and it contains a multidimensionnal array
it seems that a single array is ok, but the multidimensionnal array does not go to the browser side…
is it a bug or a feature ?
should I fill a bug report ?
it’s an array of rows, containing an array of cells. so it’s a vector as you describe it
and in the browser debugger, it does not come through.
I store it in the serialize event “js” class, it does not arrive in the updateControl event in the browser.
if I send a one dimension json array, it arrives into the updateControl event, but not with 2 dims.
Var jsDatas As New JSONItem
Try
Var rs As RowSet = mDatabase.selectSQL( sqlCode.ToUTF8)
While Not rs.AfterLastRow
Dim jsRow As New JSONItem
jsRow.Add rs.Column( pk).IntegerValue
For i As Integer=1 To rs.ColumnCount-1
jsRow.Add rs.ColumnAt( i).stringValue.toUTF8
Next i
jsDatas.Add jsRow
rs.MoveToNextRow
Wend
rs.Close
Catch ex As DatabaseException
Alerte "VNSWebSDKTable.Serialize exception: "+Str(ex.ErrorNumber), ex.Message
End Try
js.Value("dataJson") = jsDatas
jsDatas contains good values (verified using xojo debugger)
js contains good json values
js in the browser updateControl event contains all js items except the jsDatas…
Var jsDatas As New JSONItem("[]") // Set as array
Try
Var rs As RowSet = mDatabase.selectSQL( sqlCode.ToUTF8)
While Not rs.AfterLastRow
Dim jsRow() As Variant
jsRow.Add rs.Column( pk ).IntegerValue
For i As Integer=1 To rs.ColumnCount-1
jsRow.Add rs.ColumnAt( i ).stringValue.toUTF8
Next i
jsDatas.Add jsRow
rs.MoveToNextRow
Wend
rs.Close
Catch ex As DatabaseException
Alerte "VNSWebSDKTable.Serialize exception: "+Str(ex.ErrorNumber), ex.Message
End Try
js.Value("dataJson") = jsDatas
Put this in a web button pressed event. As you can see, it reaches the browser:
Var json as new JSONItem("[]")
json.Add( Array(1, 2) )
json.Add( Array(3, 4) )
// “[ [1, 2] , [3, 4] ]”
// Send it to the browser as a string into a document property called jsData
Me.ExecuteJavaScript("document.jsData='" + json.ToString + "';")
// Let's see if such string reached there
Me.ExecuteJavaScript("alert('It\'s here! : '+document.jsData);")