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"

Code: Copy
m.Put("aaData", countries)

THX
 
m looks like a map the aadata is the key the second parameter is the value.
 
Upvote 0
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
Code: Copy
Dim m As Map
m.Initialize
m.Put("aaData", GetContacts)

The GetContacts could be populated from a database by using the DBUtils class:
Code: Copy
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.
Code: Copy
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
Back
Top