Private Sub load_projects_to_table
Dim data As List
Dim prono As String
Dim prj As String
data.Initialize
prjtable.Clear
Dim c As B4XTableColumn = prjtable.AddColumn(" Nro", prjtable.COLUMN_TYPE_TEXT)
c.Width = 60dip
Dim c As B4XTableColumn = prjtable.AddColumn(" Projekti", prjtable.COLUMN_TYPE_TEXT)
c.Width = 600dip
Sleep(0)
prjtable.HeadersHeight = 30dip
prjtable.RowHeight = 23dip
prjtable.DefaultDataFormatter.GetDefaultFormat.GroupingCharacter = ""
prjselections.Initialize(prjtable)
prjselections.Mode = prjselections.MODE_SINGLE_LINE_PERMANENT
Dim rs As ResumableSub = get_projects
Wait For(rs) Complete (res As DBResult)
For Each row() As Object In res.Rows
prono = NumberFormat2(row(0), 5, 0, 0, False)
prj = " " & row(1)
data.Add(Array(prono, prj))
Next
Wait For (prjtable.SetData(data)) Complete (Unused As Boolean)
SetColumnHorizontalAlignment(prjtable.GetColumn("Projekti") , "LEFT")
Sort(prjtable,prjtable.GetColumn("Nro"),"DESC")
End Sub
Sub Sort (Table As B4XTable, Column As B4XTableColumn, SortMode As String)
For Each c As B4XTableColumn In Table.Columns
If c = Column Then
c.InternalSortMode = SortMode
Else
c.InternalSortMode = ""
End If
Next
Table.FirstRowIndex = 0
Table.Refresh
End Sub
Private Sub get_projects As ResumableSub
Dim sqls As String
If cbShowPassiiviset.Checked Then
sqls = "SELECT_ALL_FROM_PROJECTS"
Else
sqls = "SELECT_AKTIIVISET_FROM_PROJECTS"
End If
Dim com As DBCommand = CreateCommand(sqls,Null)
Dim job As HttpJob = CreateRequest.ExecuteCommand(com, Null)
Dim req As DBRequestManager = CreateRequest
Wait For (req.ExecuteQuery(com, 0, Null)) JobDone (job As HttpJob)
If job.Success Then
req.HandleJobAsync(job, "req")
Wait For (req) req_Result (res As DBResult)
req.PrintTable(res)
Else
xui.MsgboxAsync(job.ErrorMessage, "Error while reading projects")
End If
job.Release
Return res
End Sub