B4A Library [Class] Flexible Table

peacemaker

Expert
Licensed User
Longtime User
Strange, when filling the table - starting some line the cells are filled by the number, and the same if to tap the table:

B4X:
    Dim row(11) As String
    For i = 0 To CurD.RowCount - 1
        tb.AddRow(row)
    Next

    For i = 0 To tb.NumberOfRows - 1
          tb.SetValue(0, i, i)
    Next

Video, showing the process: https://drive.google.com/open?id=0B8tskcuLtEqbbkQxNHp6bTV0NTA

Seems, some strange in this Sub:
B4X:
' draw a Row, now col is hidden (width <2)
Private Sub ShowRow(Row As Int)
    For I = 0 To lbls.Length - 1
        If (Header.GetView(I).Width > 1 ) Then
            SV.Panel.AddView(lbls(I), Header.GetView(I).Left, Row * cRowHeight, Header.GetView(I).Width, cRowHeight - cLineWidth)
            lbls(I).Text = values(I)

upd: source class of Erel has the same trouble !
B4A v.6.50, Android 5.0

If to use "tb.AddRowAutomaticWidth" - no such trouble !
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
No project, just try to make a table by SetValue:
B4X:
    For i = 0 To tb.NumberOfRows - 1
          tb.SetValue(0, i, i)
    Next
and tap it later
 

grupotgr

Member
Licensed User
Longtime User


Please, I need some help. I'm stuck and I need to make progress on this project. Thanks
 

peacemaker

Expert
Licensed User
Longtime User

Please, I need some help. I'm stuck and I need to make progress on this project. Thanks
What is the trouble ?
Use a timer to wait for the typing result, then make SELECTion from SQLite by the typed text, and update the table.
 

klaus

Expert
Licensed User
Longtime User
@peacemaker
You should move Dim row(11) As String
B4X:
Dim row(11) As String
For i = 0 To CurD.RowCount - 1
    tb.AddRow(row)
Next
into the For / Next loop.
B4X:
For i = 0 To CurD.RowCount - 1
    Dim row(11) As String
    tb.AddRow(row)
Next
 
Last edited:

klaus

Expert
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.
 

Attachments

  • TableSearch.zip
    35.4 KB · Views: 340

luciano deri

Active Member
Licensed User
Longtime User
Hello. I have a very big sqlite table ( over 800.000 rows). I can upload in grid table only rows visible in screen or few more, and upload more when scroll?
Thanks
 

luciano deri

Active Member
Licensed User
Longtime User
Not inside the Table.
You need to manage it yourself.
Trying to scroll more than a few hundreds of rows is not realistic from my users point of view.

Ok, i must intercept a scroll finish event and after make a new query...
Is possible intercept scroll finisc?
Variable maxVisibleRow what do? Can i set it to help me for this problem?
 
Last edited:

luciano deri

Active Member
Licensed User
Longtime User
is there an event when scrollview is scrolled from last row? In this time i can start a new query to show some other records
 

Pintinho

Member
Licensed User
Longtime User
Hi,

Not sure if it was mentioned before but I think that row and col on the Cell_Click and LongCellClick have the row & col the wrong way around:

B4X:
Private Sub Cell_Click
    Dim rc As RowCol
    Dim L As Label
    L = Sender
    rc = L.Tag
    '    SelectRow(rc.Row)
    SelectRow(rc)
    If SubExists(cCallBack, cEventName & "_CellClick") Then
        CallSub3(cCallBack, cEventName & "_CellClick", rc.Col, rc.Row) 'should be rc.Row, rc.Col
    End If
End Sub
 

klaus

Expert
Licensed User
Longtime User
Thank you for reporting this:
You should not change in the Cell_Click and Cell_LongClick routines, it has been so since the beginning.
You should change:
#Event: CellClick(row As Int, col As Int)
#Event: CellLongClick(row As Int, col As Int)

to
#Event: CellClick(col As Int, row As Int)
#Event: CellLongClick(col As Int, row As Int)
 

luciano deri

Active Member
Licensed User
Longtime User
The only event is Private Sub SV_ScrollChanged.
You need to check there.
I have thinked this solution. What do you think about it?
B4X:
    Private LimiteQuery As Int
'Modify on class table
' the caller can set this variable
Public Sub setLimiteQuery(LQ As Int)
    LimiteQuery = LQ
End Sub
Private Sub SV_ScrollChanged(PosX As Int, PosY As Int)
....
'add thi code
    Dim n, n2 As Int
    n = maxVisibleRow + 1
    n2 = currentMax + 1
  
    If SV.ScrollingIsFinished And n2 = LimiteQuery  And Not (Fine) Then
        Fine  = True
        UltimaRiga
    End If
    If n < LimiteQuery Then
        Fine = False  
    End If
    If SV.ScrollingIsFinished And  currentMin <= 0 And    Not (Inizio) And maxVisibleRow > - 1 Then
        Inizio = True
        PrimaRiga
    End If  
    If minVisibleRow > 0 Then
        Inizio = False  
    End If
End Sub
' return to the caller when scroll stop on last and frist page

Private Sub UltimaRiga
    If SubExists(Callback, Event & "_UltimaRiga") Then
        CallSub(Callback, Event & "_UltimaRiga")
    End If
End Sub
Private Sub PrimaRiga
    If SubExists(Callback, Event & "_PrimaRiga") Then
        CallSub(Callback, Event & "_PrimaRiga")
    End If
End Sub

'Modify on projet
Sub Tabl_UltimaRiga
    Pagina = Pagina + 1
    Tabl.ClearAll
     LoadSqliteDb
End Sub
Sub Tabl_PrimaRiga
    If Pagina > 1 Then
        Pagina = Pagina - 1
         Tabl.ClearAll
         LoadSqliteDb
    End If
End Sub
Sub LoadSQLiteDB
    limitequery = 300
    Tabl.setLimiteQuery(limitequery)
    StrQuery = "SELECT ..."
    limini  = (Pagina - 1 ) * limitequery
    StrQuery = StrQuery & " LIMIT " & limini & " , " & limitequery
  
    Tabl.LoadSQLiteDB(Main.dbSql, StrQuery,False)
  
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…