B4A Library [Class] Flexible Table

klaus

Expert
Licensed User
Longtime User
@
How about I upload minimally altered custom view class with nil else?
My guess is that many users do use the sorting and it being so slow is a bit of a nuisance.
Can you please test version 3.35, the updated version with your improvements ?
 

Attachments

  • TableV3_35.zip
    108.4 KB · Views: 41

RB Smissaert

Well-Known Member
Licensed User
Longtime User
@

Can you please test version 3.35, the updated version with your improvements ?
The sorting looks fine.
Could you upload the files persons.csv and players.csv?
In my app I made it that if you do a sort on a column where all the values are the same then the sort icon will show as a rhombus icon rather than an arrow icon.
This can be useful as you will be aware then that all the values are the same.
Did you implement that?

RBS
 

klaus

Expert
Licensed User
Longtime User

Attachments

  • TableV3_35.zip
    109.8 KB · Views: 42

RB Smissaert

Well-Known Member
Licensed User
Longtime User
OK.
The default sorting bitmaps are created internally.
Therefore no need to add any image file.
But, the user can set other sorting image files.
OK, attached the altered demo project, just adding the third sorting icon.

RBS
 

Attachments

  • TableV3_35.zip
    104.9 KB · Views: 40

RB Smissaert

Well-Known Member
Licensed User
Longtime User
OK.
Will let you know if I find something else to add.

RBS
I possibly have something else to add, a lot simpler this time:
The flexible table class has this Sub to get the cell value:

B4X:
Public Sub GetValue(Col As Int, Row As Int) As String    
    Dim values() As String
    values = Data.Get(Row)
    Return values(Col)    
End Sub

This works fine, but it is based on the values in the list Data and not on the actual table label text.
I have the label text sometimes different than the values in Data, mainly for date and date-time values, based
on the data types of the table columns.

I didn't see it in your code, so I added 2 Subs to get the actual label text (the one that you will see when you see the table):

B4X:
'-------------------------------------------------------------------------------------------------------------------------
'these 2 were added as the table cell (lbl.Text) value can be different from the value in Data (mainly date and date-time)
'-------------------------------------------------------------------------------------------------------------------------
Public Sub GetCellValue(iCol As Int, iRow As Int) As String
    
    Dim lbls() As Label
    
    lbls = visibleRows.Get(iRow)
    
    Return lbls(iCol).Text
    
End Sub

Public Sub GetRowCellsValues(iRow As Int) As String()
    
    Dim i As Int
    Dim lbls() As Label
    
    lbls = visibleRows.Get(iRow)
    
    Dim arrCells(lbls.Length) As String
    
    For i = 0 To arrCells.Length - 1
        arrCells(i) = lbls(i).Text
    Next
    
    Return arrCells
    
End Sub

I might be overlooking something to get this same result, but if not it may be worth it to add these 2 Subs.
It will only be used to access visible table rows.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Sorry, but I will not add these subs because they are too specialized and only valid for the visible rows.
When you scroll the table the cells are updated with the content of the Data list, so what do you in this case ?
>> so what do you in this case?
Update the label text with formatted data from the data list. That is if column data type requires that. Just the same as in AddRow.
Having dates available in 2 states (string and int or long) is useful as you will show the string date and sort on the int/long date.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
This means that you also modified the ShowRow routine.
Yes, sorry, instead of AddRow I should have said ShowRow.
AddRow is unaltered, except for this very minor modification at the end:

B4X:
    'RBS added 01/12/2022, leaving this off seriously can slow down the loading of the table!
    If cShowStatusLine Then 
        If (lblStatusLine.IsInitialized And enableStatusLineAutoFill) Then setStatusLine(Data.Size & " rows") ' should this be automatic ?
    End If

RBS
 

klaus

Expert
Licensed User
Longtime User
The Table class has been updated to version 3.35

Replaced the original sorting functions by new ones kindly provided by forum member RB Smissaert.
Amended first scroll scrolling back to 0
Amended Header with transparent color
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…