B4A Library [Class] Flexible Table

klaus

Expert
Licensed User
Longtime User
minVisibleRow and maxVisibleRow are the previus numbers of visible rows.
currentMin and currentMax are the current numbers of visible rows, these values are calculated at the beginning of Sub SV_ScrollChanged.
And at the end of Sub SV_ScrollChanged minVisibleRow and maxVisibleRow are updated.
minVisibleRow = currentMin
maxVisibleRow = currentMax
 

grupotgr

Member
Licensed User
Longtime User
@grupotgr
Is this what you are looking for?
Clicking on the header City or Country opens a serch view.
The selected item is highlighted in the table.
I modified a bit the SearchView Class and set the Data List in the Table Class to Public.

Sorry klaus, I was not coming to work, now I'm resuming my activities! I'll try what you suggest and I keep you informed.
Thanks for the help!
 

luciano deri

Active Member
Licensed User
Longtime User
Hello Klaus, in versione 1.43 you use DoEvents, but this instruction is deprecated on versione 7.01. Could i replace with sleep(0) without problems? Or Could i continue to use DoEvents?
 

klaus

Expert
Licensed User
Longtime User
You can replace thise code
B4X:
'Makes the given row visible.
Public Sub JumpToRow(Row As Int)
    SV.VerticalScrollPosition = Row * cRowHeight
    DoEvents
    SV.VerticalScrollPosition = Row * cRowHeight
    DoEvents
End Sub

'Makes the given row visible and det it's row and colum as selected.
Public Sub JumpToRowAndSelect(Row As Int, Col As Int)
    Dim rc As RowCol
  
    rc.Row = Row
    rc.Col = Col
    SelectRow(rc)
    SV.VerticalScrollPosition = Row * cRowHeight
    DoEvents
    SV.VerticalScrollPosition = Row * cRowHeight
    DoEvents
End Sub
By this code:
B4X:
'Makes the given row visible.
Public Sub JumpToRow(Row As Int)
    Sleep(0)
    SV.VerticalScrollPosition = Row * cRowHeight
End Sub

'Makes the given row visible and det it's row and colum as selected.
Public Sub JumpToRowAndSelect(Row As Int, Col As Int)
    Dim rc As RowCol
  
    rc.Row = Row
    rc.Col = Col
    SelectRow(rc)
    Sleep(0)
    SV.VerticalScrollPosition = Row * cRowHeight
End Sub

@Erel
The Sleep(0) is needed when JumpToRow is called either from Activity_Create or Activity_Resume.

The Class has been updated to versions 1.44 and 2.19 in post#1.
 
Last edited:

Magma

Expert
Licensed User
Longtime User
Hope this routine helps who works with MSMariaDB:

Just add it at table class:

B4X:
Public Sub LoadMSMariaDB2(Data1 As List, meta As Map, AutomaticWidths As Boolean, ColumnDataTypes() As String)

If Data1.Size < 1 Then
    Return
End If
 
cAutomaticWidths = AutomaticWidths


    mNumberOfColumns = meta.get("ColumnCount")

    innerClearAll(mNumberOfColumns)
 
 
    Dim Headers(mNumberOfColumns) As String
    Dim ColumnWidths(mNumberOfColumns) As Int
    Dim HeaderWidths(mNumberOfColumns) As Int
    Dim DataWidths(mNumberOfColumns) As Int
    Dim cColumnDataType(mNumberOfColumns) As String
    Dim col, row As Int
    Dim ii As Long
    Dim dd As Double
    Dim str As String
    Dim fields As Map=Data1.Get(0)
    For col = 0 To mNumberOfColumns - 1
        If ColumnDataTypes(col) = "T" Then
            cColumnDataType(col) = "TEXT"
        Else
            cColumnDataType(col) = "NUMBER"
        End If
        Headers(col) = fields.GetKeyAt(col)
        If cAutomaticWidths = False Then
            ColumnWidths(col) = 130dip
            HeaderWidths(col) = 130dip
            DataWidths(col) = 130dip
        Else
            HeaderWidths(col) = cvs.MeasureStringWidth(Headers(col), Typeface.DEFAULT, cTextSize) + ExtraWidth
            DataWidths(col) = 0
            For row = 0 To Data1.size - 1
                Dim fields As Map=Data1.Get(row)
                str = fields.GetValueAt(col)
                If str <> Null Then
                    Select ColumnDataTypes(col)
                        Case "I"
                            ii = NumberFormat2(fields.GetValueAt(col),1,0,0,False)
                            str = ii
                        Case "R"
                            dd = NumberFormat2(fields.GetValueAt(col),1,2,2,False)
                            str = dd
                    End Select
                Else
                    str = ""
                End If
                DataWidths(col) = Max(DataWidths(col), cvs.MeasureStringWidth(str, Typeface.DEFAULT, cTextSize) + ExtraWidth)
            Next
            ColumnWidths(col) = Max(HeaderWidths(col), DataWidths(col))
        End If
    Next
    SetHeader(Headers)
    SetColumnsWidths(ColumnWidths)

    For row = 0 To Data1.size - 1

        Dim R(mNumberOfColumns), str As String
     
        Dim fields As Map=Data1.Get(row)
        For col = 0 To mNumberOfColumns - 1
            str = fields.GetValueAt(col)
            If str = Null Then
                R(col) = ""
            Else
                Select ColumnDataTypes(col)
                    Case "I"
                        ii = NumberFormat2(fields.GetValueAt(col),1,0,0,False)
                        R(col) = ii
                    Case "R"
                        dd = NumberFormat2(fields.GetValueAt(col),1,2,2,False)
                        R(col) = dd
                    Case "T"
                        R(col) = fields.GetValueAt(col)
                    Case Else '"BLOB"
                        R(col) = ""
                End Select
            End If
        Next
        AddRow(R)
    Next
 

End Sub

Way to view MSMariaDB to table is the above:

B4X:
Sub Process_Globals
dim db as MSMaria
end sub
    db.Initialize("MSQL","yourdomain","username","password","database-maria")

db.QueryASync("select * from products;","show")


Sub DisableStrictMode
Dim jo As JavaObject
jo.InitializeStatic("android.os.Build.VERSION")
If jo.GetField("SDK_INT") > 9 Then
    Dim policy As JavaObject
    policy = policy.InitializeNewInstance("android.os.StrictMode.ThreadPolicy.Builder", Null)
        policy = policy.RunMethodJO("permitAll", Null).RunMethodJO("build", Null)
        Dim sm As JavaObject
        sm.InitializeStatic("android.os.StrictMode").RunMethod("setThreadPolicy", Array(policy))
    End If

End Sub


Sub MSQL_Status(Connected As Boolean, ReConnecting As Boolean, RetriesLeft As Int)
    Log($"Connected = ${Connected}"$)
End Sub


Sub MSQL_ExecResult(meta As Map)
    Log(meta)
End Sub
Sub MSQL_BatchResult(batch As Map)
    Log(batch)
End Sub

Sub MSQL_QueryResult(Data As List, meta As Map)

    Dim m As Map = meta
    'Dim r As List
 
 
    Select Case m.Get("TaskID")
        Case "show"

            Dim cts(3) As String '3 are my fields
            cts(0)="T"
            cts(1)="T"
            cts(2)="I"
            Table1.LoadMSMariaDB2(Data, meta, True, cts)
    End Select

    db.CloseDatabase
 
End Sub

Sub MSQL_ListTables(tables As List, ms As Long)
    Log("MSQL_ListTables("&ms&"ms)")
    For i=0 To tables.Size-1
        'Log("Table "&tables.Get(i))
    Next
End Sub

MSMariaDB is a chargeable library

But if you buy it - you can use my routine for free..
 
Last edited:

Aries Abedes

Member
Licensed User
Hi,

I am trying to use the new flexible table version(2.19) in conjunction with the new DBrequestManager with resumable subs and jRDC2. This is the code where it will download data from ms sql then save it locally to sqlite

B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    'Private reqManager As DBRequestManager
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private btnSearch As Button
    Private edtSearch As EditText
    Private lblCount As Label
    Private tblDRList As Table
    Private Toolbar As ACToolBarDark
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("lDRList")
 
'    If FirstTime Then
'        reqManager.Initialize(Me, "http://192.168.1.2:9999/rdc") 'Office
'    End If
 
    Dim TestConn As HttpJob
    TestConn.Initialize("TestConn", Me)
    TestConn.Download("http://192.168.1.2:9999/test")
    TestConn.GetRequest.Timeout = 3000
 
    CheckSQLiteIfEmpty
    CallSpDownloadDR(Starter.intAreaID, Starter.strReleaseDate)
 

     
 
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

'------------------------------------------------------------------------------
'|JOB DONE - For ASYNC CALL - UI STILL RESPOND While PROCESSING SQL REQUEST   |
''------------------------------------------------------------------------------
Sub JobDone(Job As HttpJob)
    If Job.Success = True Then
        Select Job.JobName
'            Case "DBRequest"
'                reqManager.HandleJobAsync(Job, "ReqManager")
            Case "TestConn"
                ToastMessageShow("Connection to RDC server was successful.", False)
        End Select
    Else
        Log("Error: " & Job.ErrorMessage)
        Msgbox("Failed to connect to RDC server. Please check connection and try again." , "Server connection error:")
        Activity_Resume
    End If
    Job.Release
End Sub

'Sub ReqManager_Result(result As DBResult)
'     
'    '------------------------------------
'    '| LOAD DR RESULT            |
'    '------------------------------------
' 
'    If result.Tag = "DRDownload" Then 'query tag
'        tblDRList.LoadRDCResult(result,True)
'        Log(result)
'        If tblDRList.Size = 0 Then
'            Msgbox("No released DR for " & Starter.strLSRArea, "Download error:")
'            Return
'        Else
'            SaveToSQLite
'            StartActivity(aDRList)
'         
'            Activity.Finish
'        End If
'        Log(result)
'    End If
'  
'End Sub


Sub CreateRequest As DBRequestManager
    Dim req As DBRequestManager
    req.Initialize(Me, "http://192.168.1.2:9999/rdc")
    Return req
End Sub

Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = Name
    cmd.Parameters = Parameters
    Return cmd
End Sub



Sub CallSpDownloadDR(aID As Int, rDate As String)
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("dr_download", Array(aID, rDate))
    Wait for (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        req.PrintTable(res)
        tblDRList.LoadRDCResult(res, True)
        If tblDRList.Size = 0 Then
            Msgbox("No released DR for " & Starter.strLSRArea, "Download error:")
            Return
        Else
            SaveToSQLite
            StartActivity(aDRList)
            'Activity.Finish
        End If
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
    j.Release
End Sub


Sub Toolbar_MenuItemClick (Item As ACMenuItem)
 
End Sub

Sub tblDRList_CellClick(col As Int, row As Int)
 
End Sub

Sub btnSearch_Click
 
End Sub

Sub Activity_KeyUp (KeyCode As Int) As Boolean
    StartActivity(Main)
    Activity.Finish
End Sub



Sub CheckSQLiteIfEmpty
    Dim Count As Int
    Count = Starter.SQl1.ExecQuerySingleResult2 ("SELECT COUNT(entryid) FROM tblcsvdrreceivingdtl WHERE receivedby IS NULL", Array As String())
 
    If Count <> 0 Then
        DeleteUnsignedDR
    End If
End Sub

Sub SaveToSQLite
    Dim tblDrFromMSSQL As List
    Dim Items() As String
    tblDrFromMSSQL.Initialize
    For i = 0 To tblDRList.Size - 1
        Items = tblDRList.GetValues(i)
        Dim m As Map
        m.Initialize
        m.Put("CSVID",Items(0)) 'You will need to replace the columns names with the correct names
        m.Put("CSVDATE", Items(1))
        m.Put("LSR_AREAID", Items(2))
        m.Put("ENTRYID", Items(3))
        m.Put("DRID", Items(4))
        m.Put("RE_ENTRYID", Items(5))
        m.Put("EHDI", Items(6))
        m.Put("DRNO", Items(7))
        m.Put("DELDATE", Items(8))
        m.Put("OUTLETNAME", Items(9))
        m.Put("RET_NAME", Items(10))
        m.Put("USERID", Items(11))
        tblDrFromMSSQL.Add(m)
    Next
 
    Try
        DBUtils.InsertMaps(Starter.SQL1, "tblcsvdrreceivingdtl", tblDrFromMSSQL)
        lblCount.Text = tblDRList.Size
        tblDrFromMSSQL.Clear
        Msgbox("Download complete.", "Download status:")
    Catch
        Log(LastException)
    End Try
     
 

End Sub

Sub DeleteUnsignedDR
    Starter.SQl1.ExecNonQuery("DELETE FROM tblcsvdrreceivingdtl WHERE receivedby IS NULL")
End Sub

And then i get this error below

B4X:
Logger connected to:  SKK chronos_ace

--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (aselectarea) Create, isFirst = true **
** Activity (aselectarea) Resume **
5
MAKATI
** Activity (aselectarea) Pause, UserClosed = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (adownloaddr) Create, isFirst = true **
** Activity (adownloaddr) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Service (httputils2service) Start **
Tag: null, Columns: 12, Rows: 139
CSVID    CSVDATE    LSR_AREAID    ENTRYID    DRID    RE_ENTRYID    EHDI    DRNO    DELDATE    OUTLETNAME    RET_NAME    USERID 
2.0    02/23/2017    5.0    17.0    819875.0    393585.0    1.0    1189648.0    02/22/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    18.0    819874.0    393586.0    1.0    1189647.0    02/22/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    19.0    819984.0    393461.0    1.0    1189890.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    20.0    819985.0    393462.0    1.0    1189891.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    21.0    819987.0    393463.0    1.0    1189892.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    22.0    820005.0    393468.0    1.0    1189893.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    23.0    820009.0    393469.0    1.0    1189894.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    24.0    820010.0    393470.0    1.0    1189895.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    25.0    820011.0    393471.0    1.0    1189896.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    26.0    820316.0    393560.0    1.0    1190264.0    02/23/2017    CVLMK    CV MAGAZINE LANDMARK MAKATI    0.0 
2.0    02/23/2017    5.0    61.0    820269.0    393520.0    1.0    1189912.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    62.0    820272.0    393521.0    1.0    1189913.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    63.0    820273.0    393522.0    1.0    1189914.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    64.0    820264.0    393515.0    1.0    1189909.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    65.0    820265.0    393516.0    1.0    1189910.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    66.0    820266.0    393517.0    1.0    1189911.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    67.0    820298.0    393545.0    1.0    1189922.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    68.0    820301.0    393548.0    1.0    1189923.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    69.0    820303.0    393549.0    1.0    1189924.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    70.0    820285.0    393534.0    1.0    1189919.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    71.0    820286.0    393535.0    1.0    1189920.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    72.0    820291.0    393538.0    1.0    1189921.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    73.0    820282.0    393531.0    1.0    1189918.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    74.0    820280.0    393529.0    1.0    1189917.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    75.0    820277.0    393526.0    1.0    1189916.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    76.0    820275.0    393524.0    1.0    1189915.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    77.0    819960.0    393580.0    1.0    1189682.0    02/22/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    78.0    819961.0    393581.0    1.0    1189683.0    02/22/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    79.0    819962.0    393582.0    1.0    1189684.0    02/22/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    80.0    819956.0    393583.0    1.0    1189681.0    02/22/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    81.0    820314.0    393558.0    1.0    1189930.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    82.0    820315.0    393559.0    1.0    1189931.0    02/23/2017    FULLYFORT1    FULLYBOOKED THE FORT 1    0.0 
2.0    02/23/2017    5.0    83.0    820313.0    393557.0    1.0    1189929.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    84.0    819965.0    393584.0    1.0    1189685.0    02/22/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    85.0    820306.0    393551.0    1.0    1189925.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    86.0    820309.0    393553.0    1.0    1189926.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    87.0    820310.0    393554.0    1.0    1189927.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    88.0    820311.0    393555.0    1.0    1189928.0    02/23/2017    FULLYGBELT    METROBOOK - FULLY BOOKED GREENBELT    0.0 
2.0    02/23/2017    5.0    122.0    819876.0    393564.0    1.0    1189649.0    02/22/2017    MER-GLOPOS    MERCURY DRUGSTORE - GLORIETTA NORTHMALL    0.0 
2.0    02/23/2017    5.0    123.0    820022.0    393477.0    1.0    1189900.0    02/23/2017    MER-GLOPOS    MERCURY DRUGSTORE - GLORIETTA NORTHMALL    0.0 
2.0    02/23/2017    5.0    124.0    820024.0    393478.0    1.0    1189901.0    02/23/2017    MER-GLOPOS    MERCURY DRUGSTORE - GLORIETTA NORTHMALL    0.0 
2.0    02/23/2017    5.0    125.0    820025.0    393479.0    1.0    1189902.0    02/23/2017    MER-GLOPOS    MERCURY DRUGSTORE - GLORIETTA NORTHMALL    0.0 
2.0    02/23/2017    5.0    126.0    819877.0    393595.0    1.0    1189650.0    02/22/2017    MER-TAGPOS    MERCURY DRUGSTORE - TAGUIG    0.0 
2.0    02/23/2017    5.0    127.0    820016.0    393473.0    1.0    1189897.0    02/23/2017    MER-TAGPOS    MERCURY DRUGSTORE - TAGUIG    0.0 
2.0    02/23/2017    5.0    128.0    820017.0    393474.0    1.0    1189898.0    02/23/2017    MER-TAGPOS    MERCURY DRUGSTORE - TAGUIG    0.0 
2.0    02/23/2017    5.0    129.0    820018.0    393475.0    1.0    1189899.0    02/23/2017    MER-TAGPOS    MERCURY DRUGSTORE - TAGUIG    0.0 
2.0    02/23/2017    5.0    27.0    820312.0    393556.0    1.0    1190263.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    28.0    819951.0    393571.0    1.0    1189678.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    29.0    819953.0    393572.0    1.0    1189680.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    30.0    819952.0    393573.0    1.0    1189679.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    31.0    819947.0    393574.0    1.0    1189674.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    32.0    819941.0    393575.0    1.0    1189672.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    33.0    819945.0    393576.0    1.0    1189673.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    34.0    819948.0    393577.0    1.0    1189675.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    35.0    819949.0    393578.0    1.0    1189676.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    36.0    819950.0    393579.0    1.0    1189677.0    02/22/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    37.0    820254.0    393509.0    1.0    1189731.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    38.0    820255.0    393510.0    1.0    1189732.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    39.0    820256.0    393511.0    1.0    1189733.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    40.0    820258.0    393512.0    1.0    1189734.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    41.0    820261.0    393513.0    1.0    1189735.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    42.0    820263.0    393514.0    1.0    1189736.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    43.0    820267.0    393518.0    1.0    1189737.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    44.0    820268.0    393519.0    1.0    1189738.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    45.0    820274.0    393523.0    1.0    1189739.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    46.0    820276.0    393525.0    1.0    1189740.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    47.0    820278.0    393527.0    1.0    1189741.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    48.0    820279.0    393528.0    1.0    1189742.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    49.0    820281.0    393530.0    1.0    1189743.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    50.0    820283.0    393532.0    1.0    1189744.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    51.0    820284.0    393533.0    1.0    1189747.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    52.0    820307.0    393552.0    1.0    1190262.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    53.0    820324.0    393563.0    1.0    1190267.0    02/23/2017    NBSGBELT2    NATIONAL BOOKSTORE - GREENBELT    0.0 
2.0    02/23/2017    5.0    89.0    820305.0    393550.0    1.0    1190261.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    90.0    820233.0    393494.0    1.0    1189716.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    91.0    820234.0    393495.0    1.0    1189717.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    92.0    820235.0    393496.0    1.0    1189718.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    93.0    820236.0    393497.0    1.0    1189719.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    94.0    820237.0    393498.0    1.0    1189720.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    95.0    820238.0    393499.0    1.0    1189721.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    96.0    820239.0    393500.0    1.0    1189722.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    97.0    820242.0    393501.0    1.0    1189723.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    98.0    820244.0    393502.0    1.0    1189724.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    99.0    820245.0    393503.0    1.0    1189725.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    100.0    820246.0    393504.0    1.0    1189726.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    101.0    820250.0    393505.0    1.0    1189727.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    102.0    820251.0    393506.0    1.0    1189728.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    103.0    820252.0    393507.0    1.0    1189729.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    104.0    820253.0    393508.0    1.0    1189730.0    02/23/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    105.0    819918.0    393588.0    1.0    1189664.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    106.0    819931.0    393589.0    1.0    1189666.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    107.0    819934.0    393590.0    1.0    1189667.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    108.0    819935.0    393591.0    1.0    1189668.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    109.0    819936.0    393592.0    1.0    1189669.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    110.0    819938.0    393593.0    1.0    1189671.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    111.0    819937.0    393594.0    1.0    1189670.0    02/22/2017    NBS-GLORIE    NBS GLORIETTA 1    0.0 
2.0    02/23/2017    5.0    112.0    820299.0    393546.0    1.0    1190259.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    113.0    820300.0    393547.0    1.0    1190260.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    114.0    820292.0    393539.0    1.0    1190253.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    115.0    820293.0    393540.0    1.0    1190254.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    116.0    820294.0    393541.0    1.0    1190255.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    117.0    820295.0    393542.0    1.0    1190256.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    118.0    820296.0    393543.0    1.0    1190257.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    119.0    820297.0    393544.0    1.0    1190258.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    120.0    820287.0    393536.0    1.0    1189748.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    121.0    820290.0    393537.0    1.0    1189749.0    02/23/2017    NBS-SMAURA    ABACUS - SM AURA    0.0 
2.0    02/23/2017    5.0    151.0    820097.0    393489.0    1.0    1189711.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    152.0    820098.0    393490.0    1.0    1189712.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    153.0    820099.0    393491.0    1.0    1189713.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    154.0    820100.0    393492.0    1.0    1189714.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    155.0    820101.0    393493.0    1.0    1189715.0    02/23/2017    NBS-UPTOWNPM    ABACUS - UPTOWN PLACE MALL    0.0 
2.0    02/23/2017    5.0    54.0    820035.0    393485.0    1.0    1189905.0    02/23/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    55.0    820036.0    393486.0    1.0    1189906.0    02/23/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    56.0    820037.0    393487.0    1.0    1189907.0    02/23/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    57.0    820038.0    393488.0    1.0    1189908.0    02/23/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    58.0    819878.0    393587.0    1.0    1189651.0    02/22/2017    RUSMKT    RUSTAN`S - MAKATI    0.0 
2.0    02/23/2017    5.0    130.0    820020.0    393476.0    1.0    1189707.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    131.0    820015.0    393472.0    1.0    1189706.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    132.0    819988.0    393464.0    1.0    1189702.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    133.0    819992.0    393465.0    1.0    1189703.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    134.0    819994.0    393466.0    1.0    1189704.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    135.0    819997.0    393467.0    1.0    1189705.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    136.0    819982.0    393459.0    1.0    1189700.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    137.0    819983.0    393460.0    1.0    1189701.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    138.0    820026.0    393480.0    1.0    1189708.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    139.0    820028.0    393482.0    1.0    1189709.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    140.0    820319.0    393561.0    1.0    1190265.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    141.0    820321.0    393562.0    1.0    1190266.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    142.0    819869.0    393565.0    1.0    1189644.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    143.0    819870.0    393566.0    1.0    1189645.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    144.0    819872.0    393567.0    1.0    1189646.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    145.0    819860.0    393568.0    1.0    1189641.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    146.0    819865.0    393569.0    1.0    1189642.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    147.0    819867.0    393570.0    1.0    1189643.0    02/22/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    148.0    820030.0    393484.0    1.0    1189710.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    149.0    819980.0    393457.0    1.0    1189698.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    150.0    819981.0    393458.0    1.0    1189699.0    02/23/2017    SADDLE-POS    SADDLE BROWN    0.0 
2.0    02/23/2017    5.0    59.0    820027.0    393481.0    1.0    1189903.0    02/23/2017    SHANGRILA    MAKATI SHANGRI-LA HOTEL & RESORT,INC.    0.0 
2.0    02/23/2017    5.0    60.0    820029.0    393483.0    1.0    1189904.0    02/23/2017    SHANGRILA    MAKATI SHANGRI-LA HOTEL & RESORT,INC.    0.0 
Error occurred on line: 506 (Table)
java.lang.RuntimeException: Object should first be initialized (View).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.ViewWrapper.setWidth(ViewWrapper.java:135)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:339)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
    at com.emeraldheadway.dr.table._setcolumnswidths(table.java:887)
    at com.emeraldheadway.dr.table._loadrdcresult(table.java:239)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:139)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:166)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:19)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:240)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
    at anywheresoftware.b4a.BA$2.run(BA.java:360)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:207)
    at android.app.ActivityThread.main(ActivityThread.java:5728)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:679)

and this is the sub from the table class where it tells the error

B4X:
Public Sub SetColumnsWidths(Widths() As Int)
    ' clone (keep) Widths
    Dim col, row As Int
 
 
    Dim SavedWidths(Widths.Length) As Int
    Dim ColumnWidths(Widths.Length) As Int
    Dim HeaderWidths(Widths.Length) As Int
    If cAutomaticWidths = False Then
        For col = 0 To Widths.Length - 1
            SavedWidths(col) = Widths(col)
            ColumnWidths(col) = Widths(col)
            HeaderWidths(col) = Widths(col)
            DataWidths(col) = Widths(col)
        Next
    Else
        For col = 0 To Widths.Length - 1
            SavedWidths(col) = Widths(col)
            ColumnWidths(col) = Widths(col)
        Next
    End If
 
    Dim v As View
    Dim w As Int
 
    For col = 0 To Widths.Length - 1
        v = Header.GetView(col)
        w = Max(2dip, Widths(col) - cLineWidth)
        v.Width = w
        If col > 0 Then
            v.Left = Header.GetView(col - 1).Left + Widths(col - 1)
        End If
    Next
    Header.Width = Header.GetView(Widths.Length - 1).Left + Widths(Widths.Length - 1)
    SV.Panel.Width = Header.Width
    Dim lbls() As Label
    For row = 0 To visibleRows.Size - 1
        lbls = visibleRows.GetValueAt(row)
        For col = 0 To lbls.Length - 1
            lbls(col).SetLayout(Header.GetView(col).Left, lbls(col).Top, _
                Header.GetView(col).Width, cRowHeight - cLineWidth)
        Next
    Next
    lblStatusLine.Width = Header.Width
    internalPanel.Width = Header.Width
End Sub

Using the old modules seem to work fine where I jump from sub to sub to process the command but when I try to convert it this error appears. I'm sorry if i cannot explain it well. Hope someone can help me.

Thank you.

Aries
 

Attachments

  • DRzip.zip
    51.3 KB · Views: 236
Last edited:

klaus

Expert
Licensed User
Longtime User
1) In the Activity aDownloadDR you are using a Table tblDRList which is not defined in the layout nor added to the Activity !?

2) Set a breakpoint in line 125 StartActivity(aDRList) in aDownloadDR to see if the the table is loaded form there.

3) Set a breakpoint at line 1860 innerClearAll(mNumberOfColumns) in the Table class and check if the value of mNumberOfColumns in the line 1859 is bigger than 0.
 

Aries Abedes

Member
Licensed User
Hi Klaus,

Thank you for the support but unfortunately I was not able to get pass no. 2. I will test further and update what would be the workaround for this. For now I will just continue to use the old DBRequestManager module.

Thank you.

Aries
 

Aries Abedes

Member
Licensed User
Hi,

I have tried to comment the
B4X:
SetColumnsWidths (ColumnWidths)
from
B4X:
Public Sub LoadRDCResult(Result As DBResult, AutomaticWidths As Boolean)
then I was able to continue but only get a single row from the result and the innerClearAll(mNumberOfColumns) in the Table class has a value of 5.

Any suggestions?

Thank you.
 

Aries Abedes

Member
Licensed User
I'm so sorry... please disregard my post. It was my fault.. I'm still using the old LoadRDCResult Sub that I may have messed up.

Thank you.

Aries
 

vecino

Well-Known Member
Licensed User
Longtime User
Hi, why are there two different versions?
What makes them different?
Tablev2.19 and Tablev1.44
 

vecino

Well-Known Member
Licensed User
Longtime User
Thank you very much for the information.
Then I will use version 2.19
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, now how do I tell you how many columns?
And how much is the width of each column?
Thank you.
 

Claudio Oliveira

Active Member
Licensed User
Longtime User
Starting to use this class now, and I noticed that the StatusLine is too close to the table border, so I added the following line to InitTable sub, before the pnlTable.AddView(internalPanel, 0, 0, cWidth, 0) line (class line 414):

B4X:
SetPadding(lblStatusLine, 4dip, 2dip, 4dip, 2dip)

I'm not sure this is the right approach, but it aligned the StatusLine with the table header and improved it's readability.

Regards
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…