Hi to all
I'm approaching to use datatable object (the same used by erel in webapp example - DBUtils) to load from time to time several tables in the archive.
The first loading is ok but the next show this message:
I added in jq.RunMethod "bRetrive": True) first the loading table ma is the same.
This my sub:
Thanks for suggestions
I'm approaching to use datatable object (the same used by erel in webapp example - DBUtils) to load from time to time several tables in the archive.
The first loading is ok but the next show this message:
I added in jq.RunMethod "bRetrive": True) first the loading table ma is the same.
This my sub:
B4X:
Sub btarchivi_Click (Params As Map)
If listarchivi.GetVal.Value = "" Then Return 'in listarchivi i have the table name
Dim l As List
l.Initialize
Dim sql As SQL = pool.GetConnection
DBUtils.ExecuteList(sql, "SHOW columns FROM " & listarchivi.GetVal.Value, Null, 0, l)
sql.Close
tabledata.SetHtml(DBUtils.PreparaHeaderHtml(l))
Dim sql As SQL = pool.GetConnection
sql.BeginTransaction
DBUtils.FillTable(ws, tabledata, sql.ExecQuery("SELECT * FROM " & listarchivi.GetVal.Value))
sql.TransactionSuccessful
sql.Close
End Sub
Public Sub FillTable(ws As WebSocket, jq As JQueryElement, rs As ResultSet)
Dim data As List
data.Initialize
Do While rs.NextRow
Dim row As List
row.Initialize
For c = 0 To rs.ColumnCount - 1
Dim val As String = rs.GetString2(c)
row.Add(WebUtils.EscapeHtml(val))
Next
data.Add(row)
Loop
rs.Close
jq.RunMethod("dataTable", Array As Object(CreateMap("aaData": data, "bFilter": True, _
"bPaginate": True)))
ws.RunFunction("addSelectionToTable", Array As Object(jq.Id, "tabledata_SelectedRowChanged"))
ws.Eval("$(arguments[0]).dataTable().fnClearTable()", Array As Object(jq.Id))
ws.Eval("$(arguments[0]).dataTable().fnAddData(arguments[1])", Array As Object(jq.Id, data))
End Sub
Sub PreparaHeaderHtml(lista As List) As String
Dim sb As StringBuilder
sb.Initialize
sb.Append($"<thead>
<tr>
"$)
For i = 0 To lista.Size - 1
sb.Append("<th>").Append(lista.Get(i)).Append("</th>")
Next
sb.Append($"</tr>
</thead>"$)
Return sb.ToString
End Sub
Thanks for suggestions