B4A Library [Class] Flexible Table

Kanne

Member
Licensed User
Longtime User
better (no out of bounds), but still some gaps:
"NumberOfFixedColumns" resets header color - that's no problem, so I have to call it first.
But don't know the order to call the other settings - every version has some small problems:
Example 1 (header faulty):
example 1:
    tableRun.ShowStatusLine = False
    tableRun.NumberOfFixedColumns = 2
    tableRun.SetAutomaticWidths

    tableDes.ShowStatusLine = False
    tableDes.NumberOfFixedColumns = 2
    tableDes.SetAutomaticWidths

'    tableRun.UseColumnColors = True
'    tableRun.SetColumnColors(myColors1)
    tableRun.SetHeader(myHeader)
    tableRun.SetHeaderColors(myColors2) ' all to white
    tableRun.SetHeaderTextColors(myColors1)

'    tableDes.UseColumnColors = True
'    tableDes.SetColumnColors(myColors1)
    tableDes.SetHeader(myHeader)
    tableDes.SetHeaderColors(myColors2) ' all to white
    tableDes.SetHeaderTextColors(myColors1)
    
    tableRun.hideCol(0)
    tableRun.hideCol(4)
    tableRun.hideCol(5)
    tableDes.hideCol(0)
    tableDes.hideCol(4)
    tableDes.hideCol(5)

Example 2: (hidden cols shown, header col1 wrong color and faulty border):
Example 2:
    tableRun.ShowStatusLine = False
    tableRun.NumberOfFixedColumns = 2
    tableRun.SetAutomaticWidths

    tableDes.ShowStatusLine = False
    tableDes.NumberOfFixedColumns = 2
    tableDes.SetAutomaticWidths
    
    tableRun.hideCol(0)
    tableRun.hideCol(4)
    tableRun.hideCol(5)
    tableDes.hideCol(0)
    tableDes.hideCol(4)
    tableDes.hideCol(5)
    
'    tableRun.UseColumnColors = True
'    tableRun.SetColumnColors(myColors1)
    tableRun.SetHeader(myHeader)
    tableRun.SetHeaderColors(myColors2) ' all to white
    tableRun.SetHeaderTextColors(myColors1)

'    tableDes.UseColumnColors = True
'    tableDes.SetColumnColors(myColors1)
    tableDes.SetHeader(myHeader)
    tableDes.SetHeaderColors(myColors2) ' all to white
    tableDes.SetHeaderTextColors(myColors1)
 

Attachments

  • ex1.jpg
    191.3 KB · Views: 135
  • ex2.jpg
    178.7 KB · Views: 149
  • Test Table.zip
    9.7 KB · Views: 109

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Not sure now if I should post here on in the general questions forum, but in any case:

Come across a strange scrolling bug, where a table is loaded and you do a down scroll and then at the end it scrolls automatically back to scrolling position zero.
This only happens once at the first scroll in that particular table and I have seen it only in one particular table (I have some 30 of these tables in this app).
This also doesn't happen when you do a horizontal scroll before the down scroll.
It is proving very difficult to debug this as stepping through it in debug mode shows nil to explain this.
I have added logs and that shows something like this when this happens:

SV2_ScrollChanged, PosY: 5
Scroll, PosY: 5
SVF_ScrollChanged, Position: 5
Scroll, PosY: 5
SV2_ScrollChanged, PosY: 10
Scroll, PosY: 10
SVF_ScrollChanged, Position: 10
Scroll, PosY: 10
SV2_ScrollChanged, PosY: 15
Scroll, PosY: 15
SVF_ScrollChanged, Position: 15
Scroll, PosY: 15
SV2_ScrollChanged, PosY: 18
Scroll, PosY: 18
SV2_ScrollChanged, PosY: 20
Scroll, PosY: 20
SVF_ScrollChanged, Position: 18
Scroll, PosY: 18
SV2_ScrollChanged, PosY: 18
SV2_ScrollChanged, PosY: 25
Scroll, PosY: 25
SVF_ScrollChanged, Position: 20
Scroll, PosY: 20
SV2_ScrollChanged, PosY: 20
SV2_ScrollChanged, PosY: 30
Scroll, PosY: 30
SVF_ScrollChanged, Position: 25
Scroll, PosY: 25
SV2_ScrollChanged, PosY: 25
SV2_ScrollChanged, PosY: 34
Scroll, PosY: 34
SVF_ScrollChanged, Position: 30
Scroll, PosY: 30
SV2_ScrollChanged, PosY: 30
SV2_ScrollChanged, PosY: 37
Scroll, PosY: 37
SVF_ScrollChanged, Position: 34
Scroll, PosY: 34
SV2_ScrollChanged, PosY: 34
SV2_ScrollChanged, PosY: 40
Scroll, PosY: 40
SVF_ScrollChanged, Position: 37
Scroll, PosY: 37
SV2_ScrollChanged, PosY: 37
SV2_ScrollChanged, PosY: 42
Scroll, PosY: 42
SVF_ScrollChanged, Position: 40
Scroll, PosY: 40
SV2_ScrollChanged, PosY: 40
SV2_ScrollChanged, PosY: 44
Scroll, PosY: 44
SVF_ScrollChanged, Position: 42
Scroll, PosY: 42
SV2_ScrollChanged, PosY: 42
SV2_ScrollChanged, PosY: 46
Scroll, PosY: 46
SVF_ScrollChanged, Position: 44
Scroll, PosY: 44
SV2_ScrollChanged, PosY: 44
SV2_ScrollChanged, PosY: 48
Scroll, PosY: 48
SVF_ScrollChanged, Position: 46
Scroll, PosY: 46
SV2_ScrollChanged, PosY: 46
SV2_ScrollChanged, PosY: 49
Scroll, PosY: 49
SVF_ScrollChanged, Position: 48
Scroll, PosY: 48
SV2_ScrollChanged, PosY: 48
SV2_ScrollChanged, PosY: 50
Scroll, PosY: 50
SVF_ScrollChanged, Position: 49
Scroll, PosY: 49
SV2_ScrollChanged, PosY: 49
SV2_ScrollChanged, PosY: 51
Scroll, PosY: 51
SVF_ScrollChanged, Position: 50
Scroll, PosY: 50
SV2_ScrollChanged, PosY: 50
SV2_ScrollChanged, PosY: 52
Scroll, PosY: 52
SVF_ScrollChanged, Position: 51
Scroll, PosY: 51
SV2_ScrollChanged, PosY: 51
SV2_ScrollChanged, PosY: 53
Scroll, PosY: 53
SVF_ScrollChanged, Position: 52
Scroll, PosY: 52
SV2_ScrollChanged, PosY: 52
SV2_ScrollChanged, PosY: 53
Scroll, PosY: 53
SVF_ScrollChanged, Position: 53
Scroll, PosY: 53
SV2_ScrollChanged, PosY: 54
Scroll, PosY: 54
SVF_ScrollChanged, Position: 54
Scroll, PosY: 54
SVF_ScrollChanged, Position: 0
Scroll, PosY: 0
SV2_ScrollChanged, PosY: 0
SVF_ScrollChanged, Position: 0
Scroll, PosY: 0

So, where does the zero come from in the below line?
SVF_ScrollChanged, Position: 0

It is only a minor problem, but I would like to understand it and fix it.
I am running version 2.26 with added alterations, but no alterations to do with scrolling.
I had made an alteration before to do with scrolling, but reversed that in case it had to do
with this problem.

RBS
 

klaus

Expert
Licensed User
Longtime User
Sorry, it is impossible to give any advice without more detailed information.
You say you are using version 2.26 with added alterations.
But your logs show SV2_ScrollChanged and SVF_ScrollChanged which means that you use a fixed first column.
But this was introduced in version 3.05 !?
So, what did you change where and how, i do not know only you it.
Do mix different versions of the Flexible Table ?
Sorry again, but without more detailed information impossible to help.
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
No problem, I can see the information was too little.
I have 2.26, based on the comments at the start of the class:

B4X:
'Table CustomView

'Version 2.26
'added the LoadSQLiteDB3 method using SQL.ExecQuery2 instead of SQL.ExecQuery

'Version 2.25
'added the UpdateCell method

'Version 2.24
'amended a minor error

'Version 2.22
'improved JumpToRowAndSelect scrolls horizontally to the selected column

I don't think I am using a fixed column.
The alterations have nil to do with scrolling as far as I can see. Mainly code to do with faster sorting and also with processing the incoming table data and
displaying it in the rows in a different way, eg to do with dates and date-time values.
I can post the class as I currently have it.

The other option is for me to move to the latest version, but that will involve quite a bit of work I guess.

RBS
 

klaus

Expert
Licensed User
Longtime User
Well, where do these logs SV2_ScrollChanged and SVF_ScrollChanged come from !?
In version 2.26 these routines do not exist !?
Do you declare a more recent version somewhere else ?
Again without knowing what you have done and how , i cannot help.
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Well, where do these logs SV2_ScrollChanged and SVF_ScrollChanged come from !?
In version 2.26 these routines do not exist !?
Do you declare a more recent version somewhere else ?
Again without knowing what you have done and how , i cannot help.
Well, I must have a version then that is 3.05 or later.
This is where the logs come from:

B4X:
Private Sub SVF_ScrollChanged(Position As Int)
    
    SVFScrolls = True
    
    Log("SVF_ScrollChanged, Position: " & Position)
    
    If SV2Scrolls = False Then
        Scroll(SV2PosX, Position)
        SV2.VerticalScrollPosition = Position
    End If
    
    SVFScrolls = False
    
End Sub

Private Sub SV2_ScrollChanged(PosX As Int, PosY As Int)
    
    SV2Scrolls = True
    
    Log("SV2_ScrollChanged, PosY: " & PosY)
    
    If SVFScrolls = False Then
        Scroll(PosX, PosY)
        SV2PosX = PosX
        SVF.ScrollToNow(PosY)
    End If

    SV2Scrolls = False
    
End Sub

Private Sub Scroll(PosX As Int, PosY As Int)
    
    Dim i As Int
    Dim currentMin As Int
    Dim currentMax As Int
    
    Log("Scroll, PosY: " & PosY)
    
    currentMin = Max(0, PosY / cRowHeight - 30)
    currentMax = Min(Data.Size - 1, (PosY + SV2.Height) / cRowHeight + 30)
    
    If minVisibleRow > -1 Then
        If minVisibleRow < currentMin Then
            'need to hide the upper rows
            For i = minVisibleRow To Min(currentMin - 1, maxVisibleRow)
                HideRow(i)
            Next
        Else If minVisibleRow > currentMin Then
            'need to show the upper rows
            For i = currentMin To Min(minVisibleRow - 1, currentMax)
                ShowRow(i)
            Next
        End If
        If maxVisibleRow > currentMax Then
            'need to hide the lower rows
            For i = maxVisibleRow To Max(currentMax + 1, minVisibleRow) Step -1
                HideRow(i)
            Next
        Else If maxVisibleRow < currentMax Then
            'need to show the lower rows
            For i = currentMax To Max(maxVisibleRow + 1, currentMin) Step -1
                ShowRow(i)
            Next
        End If
    End If
    
    minVisibleRow = currentMin
    maxVisibleRow = currentMax
    Header.Left = -PosX + mFirstColumnsWidth
    lblStatusLine.Left = - PosX
    
End Sub

In any case I will move to the latest version as there must be some benefit in that and add my additions/alterations.
Then I will see if the problem still exists and if so let you know.
As said it really is a very minor problem only.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Well, where do these logs SV2_ScrollChanged and SVF_ScrollChanged come from !?
In version 2.26 these routines do not exist !?
Do you declare a more recent version somewhere else ?
Again without knowing what you have done and how , i cannot help.
I have moved now to the latest version, 3.30, that is with the table custom view.
It didn't solve the mentioned problem and I didn't expect that as I can't see that many changes that might be relevant to the problem.
The problem is caused by innerClearAll as that can reset all the scroll positions. I commented out these in innerClearAll:

B4X:
Private Sub innerClearAll(vNumberOfColumns As Int, ClearData As Boolean)
    
    SelectedRows.Initialize
    SV2.Panel.RemoveAllViews
    SVF.Panel.RemoveAllViews
    mNumberOfColumns = vNumberOfColumns
    
    Dim Drawable1(mNumberOfColumns) As Object
    Dim Drawable2(mNumberOfColumns) As Object
    Dim SelectedDrawable(mNumberOfColumns) As Object
    Dim cAlignments(mNumberOfColumns) As Int
    Dim cHeaderAlignments(mNumberOfColumns) As Int
    Dim cTypeFaces(mNumberOfColumns) As Typeface
    Dim cHeaderTypeFaces(mNumberOfColumns) As Typeface
    
    If cUseColumnColors = False Then
        If lstRowColors.Size > 0 Then
            For i = 0 To lstRowColors.Size - 1
                Private cds(mNumberOfColumns) As Object
                Private color = lstRowColors.Get(i) As Int
                For col = 0 To mNumberOfColumns - 1
                    Private cdi As ColorDrawable
                    cdi.Initialize(color, 0)
                    cds(col) = cdi
                Next
                lstRowDrawables.Add(cds)
            Next
        End If
        
        For i = 0 To mNumberOfColumns - 1
            Dim cd1, cd2, cd3 As ColorDrawable
            cd1.Initialize(cRowColor1, 0)
            cd2.Initialize(cRowColor2, 0)
            cd3.Initialize(cSelectedRowColor, 0)
            Drawable1(i) = cd1
            Drawable2(i) = cd2
            SelectedDrawable(i) = cd3
            If MultiAlignments = False Or cAlignments0.Length < mNumberOfColumns Then
                cAlignments(i) = cAlignment
            Else
                cAlignments(i) = cAlignments0(i)
            End If
            If MultiTypeFace = False  Or cTypeFaces0.Length < mNumberOfColumns Then
                cTypeFaces(i) = cTypeFace
            Else
                cTypeFaces(i) = cTypeFaces0(i)
            End If
            
            If HeaderMultiAlignments = False  Or cHeaderAlignments0.Length < mNumberOfColumns Then
                cHeaderAlignments(i) = cHeaderAlignment
            Else
                cHeaderAlignments(i) = cHeaderAlignments0(i)
            End If
            If HeaderMultiTypeFace = False  Or cHeaderTypeFaces0.Length < mNumberOfColumns Then
                cHeaderTypeFaces(i) = cHeaderTypeFace
            Else
                cHeaderTypeFaces(i) = cHeaderTypeFaces0(i)
            End If
        Next
    Else
        For i = 0 To mNumberOfColumns - 1
            Private cd1, cd2, cd3 As ColorDrawable
            cd1.Initialize(cColumnColors(i), 0)
            cd2.Initialize(cColumnColors(i), 0)
            cd3.Initialize(cSelectedRowColor, 0)
            Drawable1(i) = cd1
            Drawable2(i) = cd2
            SelectedDrawable(i) = cd3
            If MultiAlignments = False Or cAlignments0.Length < mNumberOfColumns Then
                cAlignments(i) = cAlignment
            Else
                cAlignments(i) = cAlignments0(i)
            End If
            If MultiTypeFace = False  Or cTypeFaces0.Length < mNumberOfColumns Then
                cTypeFaces(i) = cTypeFace
            Else
                cTypeFaces(i) = cTypeFaces0(i)
            End If
            
            If HeaderMultiAlignments = False  Or cHeaderAlignments0.Length < mNumberOfColumns Then
                cHeaderAlignments(i) = cHeaderAlignment
            Else
                cHeaderAlignments(i) = cHeaderAlignments0(i)
            End If
            If HeaderMultiTypeFace = False  Or cHeaderTypeFaces0.Length < mNumberOfColumns Then
                cHeaderTypeFaces(i) = cHeaderTypeFace
            Else
                cHeaderTypeFaces(i) = cHeaderTypeFaces0(i)
            End If
        Next
    End If
    
    Dim cd4 As ColorDrawable
    cd4.Initialize(cSelectedCellColor, 0)
    SelectedCellDrawable = cd4

    SV2.Panel.Height = 0
    SVF.Panel.Height = 0

    'SelectedRow = -1
    SelectedCol = -1
    minVisibleRow = -1
    maxVisibleRow = 0
    If ClearData = True Then
        Data.Initialize
    End If
    LabelsCache.Initialize
    visibleRows.Initialize

    'SV2.VerticalScrollPosition = 0
    'SVF.ScrollPosition = 0
    
    For i = 1 To 80 'fill the cache to avoid delay on the first touch
        LabelsCache.Add(CreateNewLabels)
    Next
    
    If IsVisible Then
        'SV2_ScrollChanged(0, 0)
        Log("innerClearAll")
        'SVF_ScrollChanged(0)
    End If
    
    If (lblStatusLine.IsInitialized And enableStatusLineAutoFill = True) Then setStatusLine(Data.Size & " rows") ' should this be automatic ?
    
End Sub

This solved the problem and sofar not any detrimental effects from leaving these lines out, but will investigate this more thoroughly.

RBS
 

fishwolf

Well-Known Member
Licensed User
Longtime User
Hi,

i have setted Corner Radius to 20 from Designer into Table example, but doesn't work fine

Suggestion?

Thanks
 

fishwolf

Well-Known Member
Licensed User
Longtime User
What exactly do you want to do and what do you expect ?
Setting the any CornerRadius has no meaning to me.
CornerRadius for what outer frame, each cell ?
To me it does not make sense.
outer frame Top right and left corner, similato to:

 

Mahares

Expert
Licensed User
Longtime User
outer frame Top right and left corner, similato to:
Sorry, but i will not add this
Let me start by saying I seldom used FlexibleTable, but because I was able to do something like what you wanted in B4XTable, I tinkered a little bit with klaus 's class version 3.30 and added the following code and got the outcome you are looking for. See screenshot
My code was added in Public Sub SetHeader(Values() As String) between this line: Left = Left + ColumnWidths(col) and this line: Next.
B4X:
         'start mahares
        Dim cls(2) As Int
        cls(0) = Colors.RGB(24,122,12)
        cls(1) = Colors.RGB(24,184,13)
        Dim gd As GradientDrawable
        gd.Initialize("TOP_BOTTOM", cls)
        lbl.Background = gd
        Dim jo As JavaObject = lbl.Background
        Dim x As Int=20dip
        If col = 0 Then
            jo.RunMethod("setCornerRadii", Array(Array As Float(x, x, 0, 0, 0, 0, 0, 0)))  ' corner rounded  top left
        Else if col = mNumberOfColumns - 1 Then
            jo.RunMethod("setCornerRadii", Array(Array As Float(0, 0, x, x, 0, 0, 0, 0)))  ' corner rounded top right
        End If
        'end mahares
You or klaus if he chooses so, can of course change the colors and place, modify and move the code more appropriately and make it more fitting for your project and the class.


B4X:
 

fishwolf

Well-Known Member
Licensed User
Longtime User
Thank you very much

Where i can find the same solution for B4XTable?
 

Mahares

Expert
Licensed User
Longtime User
Where i can find the same solution for B4XTable?
Since this thread is exclusively for FlexibleTable, please create a new thread in the Question forum for B4XTable. Put your code and or project there and ask the question there. Soemone will answer you. If I see it and still not answered, I will answer it for you.
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Handled this now in a better way as commenting out these 2 lines:

B4X:
    If IsVisible Then
        'SV2_ScrollChanged(0, 0)
        Log("innerClearAll")
        'SVF_ScrollChanged(0)
    End If

at bottom of Sub innerClearAll, caused rare problems with the table display in that some rows remained
grey.

Instead only commenting out this line in innerClearAll:

B4X:
SVF.ScrollPosition = 0

Solves the mentioned problem, without any detrimental effect I have seen so far.
Why this problem only occurred in one particular table remains a mystery to me as there is nil I can see that is different compared
to many other flexible table I have in my app.

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