B4J Question q: Table report with Export feature

besoft

Active Member
Licensed User
Longtime User
I study the case, and I can not find the answer, what means the piece of code: "aaData"

B4X:
m.Put("aaData", countries)

THX
 

Daestrum

Expert
Licensed User
Longtime User
m looks like a map the aadata is the key the second parameter is the value.
 
Upvote 0

rwblinn

Well-Known Member
Licensed User
Longtime User
Hi,

By default jQuery DataTables use the "aaData" property of the returned data which is an Array of Arrays with one entry for each column in the table.
Example
B4X:
Dim m As Map
m.Initialize
m.Put("aaData", GetContacts)

The GetContacts could be populated from a database by using the DBUtils class:
B4X:
Public Sub GetContacts As List
  Dim l As List : l.Initialize
  l = DBUtils.ExecuteMemoryTable(sqlObj, "SELECT * FROM CONTACTS ORDER BY Name ASC", Null, 0)
  Return l
End Sub

The Map m can then be used to generate a JSON string which can be returned as a response to the server:
This will be used by the DataTable in the html file to load data from an external source by using parameter sAjaxSource in document get ready.
B4X:
Dim jg As JSONGenerator
jg.Initialize(m)
resp.ContentType = "application/json"   
resp.Write(jg.ToString)

See also B4J HowTo > WebApps jQuery > jQuery UI DataTable
 
Upvote 0
Top