B4A Library [Class] Flexible Table

This thread will be used by Erel, Melamoud and myself to discuss / post new releases of the Table class.

The table class is a flexible UI component that enable scrollable table like UI, with sortable columns, multiselect rows etc

the table is very efficient, maintaining labels only for visible rows

old thread with details : http://www.b4x.com/forum/additional...view-supports-tables-any-size.html#post110901

The class depend on following libraries:
- StringUtils (standard)
- SQL (standard)
- JavaObject (standard)
- B4XCollections (standard)
- ScrollView2D (additional)

List of major features.
1. scrollable table UI
2. sortable columns
3. select a row, cell or multi select rows
4. callback for selection / click a cell / row
5. callback for long click action
6. read / write to CSV file

Current version --> 3.35 Custom View
Current version --> 1.44 Class

Other complementary routines:

Load data with the Remote Database Connector.


EDIT: LucaMs has written a routine to fill a table with a Remote Database Connector query result see post 182.
The routine hasn't been added into the Class for the reasons explained in post 183.
A sample program can be found HERE.

Code:
B4X:
'load data from a RDC Request
'Result = DBResult object got from a RDC request
'AutomaticWidths  True > set the column widths automaticaly
'Written by LucasMs
Public Sub LoadRDCResult(Result As DBResult, AutomaticWidths As Boolean)
    cAutomaticWidths = AutomaticWidths
    NumberOfColumns = Result.Columns.Size
    innerClearAll(NumberOfColumns)

    Dim Headers(NumberOfColumns) As String
    Dim ColumnWidths(NumberOfColumns) As Int
    Dim HeaderWidths(NumberOfColumns) As Int
    Dim DataWidths(NumberOfColumns) As Int
    Dim col, row As Int
    Dim str As String
    For col = 0 To NumberOfColumns - 1
        Headers(col) = Result.Columns.GetKeyAt(col)
        If AutomaticWidths = False Then
            ColumnWidths(col) = 130dip
            HeaderWidths(col) = 130dip
            DataWidths(col) = 130dip
        Else
            HeaderWidths(col) = cvs.MeasureStringWidth(Headers(col), Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth
            DataWidths(col) = 0

            Dim FieldValue As Object
            For row = 0 To Result.Rows.Size - 1
                Dim Record() As Object = Result.Rows.Get(row)
                FieldValue = Record(col)
                If GetType(FieldValue) = "java.lang.String" Then
                    DataWidths(col) = Max(DataWidths(col), cvs.MeasureStringWidth(str, Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth)
                End If
            Next
            ColumnWidths(col) = Max(HeaderWidths(col), DataWidths(col))
        End If
    Next
    SetHeader(Headers)
    SetColumnsWidths(ColumnWidths)

    For Each Record() As Object In Result.Rows
        Dim R(NumberOfColumns) As String
        Dim FieldV As String
        For col = 0 To NumberOfColumns - 1
            FieldV = Record(col)
            R(col) = FieldV
        Next
        AddRow(R)
    Next
End Sub

This is another routine updated by cimperia in post #392 using a Map for the columns and a List for the rows.
B4X:
'load data from a RDC Request
'A RDC request returns a DBResult object, therefore this method
'could be called as is:
'LoadRDCResult(DBResult.Columns, DBResult.Rows, True)
'AutomaticWidths  True > set the column widths automaticaly
'Written by LucasMs
Public Sub LoadRDCResult(Columns As Map, Rows As List, AutomaticWidths As Boolean)
  cAutomaticWidths = AutomaticWidths
  NumberOfColumns = Columns.Size
  innerClearAll(NumberOfColumns)

  Dim Headers(NumberOfColumns) As String
  Dim ColumnWidths(NumberOfColumns) As Int
  Dim HeaderWidths(NumberOfColumns) As Int
  Dim DataWidths(NumberOfColumns) As Int
  Dim col, row As Int
  Dim str As String
  For col = 0 To NumberOfColumns - 1
    Headers(col) = Columns.GetKeyAt(col)
    If AutomaticWidths = False Then
      ColumnWidths(col) = 130dip
      HeaderWidths(col) = 130dip
      DataWidths(col) = 130dip
    Else
      HeaderWidths(col) = cvs.MeasureStringWidth(Headers(col), Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth
      DataWidths(col) = 0

      Dim FieldValue As Object
      For row = 0 To Rows.Size - 1
        Dim Record() As Object = Rows.Get(row)
        FieldValue = Record(col)
       If GetType(FieldValue) = "java.lang.String" Then
         DataWidths(col) = Max(DataWidths(col), cvs.MeasureStringWidth(str, Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth)
       End If
      Next
      ColumnWidths(col) = Max(HeaderWidths(col), DataWidths(col))
    End If
  Next
  SetHeader(Headers)
  SetColumnsWidths(ColumnWidths)

  For Each Record() As Object In Rows
    Dim R(NumberOfColumns) As String
    Dim FieldV As String
    For col = 0 To NumberOfColumns - 1
      FieldV = Record(col)
      R(col) = FieldV
    Next
    AddRow(R)
  Next
End Sub


Load data from a MSMariaDB database.

Another routine for loading data from a MSMariaDB database can be found in post#727.
Thanks to @Magma.

Updates:
EDIT: 2024.04.21 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

EDIT: 2024.01.13 Version 3.33
Changed possible values for DataType
TEXT and NUMBER become T, R and I
Amended problem with column colors
Amended problems with SetHeaderColors and SetHeaderTextColors

Version 3.32
Amended Header and HeaderFirst problem in SaveCSVFromTable
Moved If (lblStatusline... from AddRow to ShowRow

Version 3.31
Added SingleLine property for the Designer
Added StatusLineHeight as a property
Added FastScrollLabelMaxChars as a property

EDIT: 2021.06.28 Version 3.30
Added a check for none numeric values for numeric sorting.

EDIT: 2021.06.28 Version 3.29
Amended problem with column colors
Version 3.28
Added NumberOfColumns in the code
Added TopRowIndex method
Version 3.27
Amended MultiSelect EDIT: 2020.09.02 Version 3.26
Amended problem with sort with remove accents
Amended problem with SetRowColorN
Added SetCellAlignmentColN method
Added SetHeaderAlignmentColN method

EDIT: 2020.08.05 Version 3.24
Amended problem with JumpToRowAndSelect not being selected.
Amended error when setting RowHeight before the table initialized

EDIT: 2020.06.19 Version 3.22
Amended error in the insertRowAt routine.

EDIT: 2020.05.25 Version 3.21
Amended bug with TextSize in fixed columns

EDIT: 2020.05.16 Version 3.20
Added fast scroll feature
Version 3.19
Improved automatic width calculation and hidden columns
Version 3.18
Added a check in RemoveRowColorN to ensure that Row is not out of bounds
Added ShowRow event
Amended automatic width calculations
Amended hidden column width problem

EDIT: 2020.04.21 Version 3.17
Amended HeaderHight problem with fixed columns

EDIT: 2020.04.21 Version 3.16
Amended two errors.

EDIT: 2020.04.14 Version 3.14
Added the methods below
- LoadSQLiteDB4(SQLite As SQL, Query As String, AutomaticWidths As Boolean)
loads SQLite data with data type checking
- LoadSQLiteDB5(SQLite As SQL, Query As String, Values() As String, AutomaticWidths As Boolean).
loads SQLite data with data type checking , similar to LoadSQLiteDB4 but for parametrized queries.
- GetColumnDataTypes As String(), returns an Array with the data type for each column.
- GetColumnDataType(Column As Int) As String, returns the data type of the fiven column.
Added the InnerTotalWidth property, read only.
Added multiple first fiexed columns
Added line colors

EDIT: 2020.03.10 Version 3.10
Amended bug reported HERE

EDIT: 2020.03.06 Version 3.09
Amended bug reported HERE.

EDIT: 2020.02.29 Version 3.08
Amended SetHeaderTypefaces method problem reprted HERE.
Added HeaderTypeface property.

EDIT: 2020.01.08 Version 3.07
Amended bug ShowStatisLine = False property bug.
Added MultiSelect property to Designer properties.
You need to open and close the Designer when you use the new version the first time to make the MultiSelect property active.

EDIT: 2019.12.28 Version 3.06
Amened some bugs

EDIT: 2019.12.25 Version 3.05
Added FirstColumnFixed property which allows to fix the first column.
Attention: You need to open and close the Designer to make the new property active.

EDIT: 2019.11.15 Version 3.04
- Added SelectedRowTextColor and SlectedCellTextColor properties
- Added ZeroSelections property, True > when a selected row is pressed it will be unselected False > it remains selected.

EDIT: 2019.11.12 Version 3.03
- Changed JumpToRowAndSelect(Row As Int, Col As Int) to JumpToRowAndSelect(Col As Int, Row As Int)
- Changed LoadSQLiteDB2 signature. Replaced the possible values from "T", "I", "R" to "TEXT", "NUMBER" for coherence with SetColumnDataTypes.
- Added internal sorting bitmaps, avoids loading the image files into the Files folder.
- Added two new properties: SortBitmapWidth and SortBitmapColor.
- Added SetCustomSortingBitmaps method, which allows to use custom bitmaps instead of the internal ones.
Attention: You need to open and close the Designer to make the new properties active.
Attention: You need to invert the parameters in JumpToRowAndSelect.

EDIT: 2019.07.04 Version 3.02
Amended error reported in post #887

EDIT: 2019.06.26 Version 3.01
Amended SingleLine property setting in the code

EDIT: 2019.04.05 Version 3.00
Amended SetColumnColors and SetTextColors
Removed Reflection library dependency

EDIT: 2018.04.11 Version 2.29
Version 2.27
set the two variables sortedCol and sortingDir to Public instaed of Private
added RemoveAccent routine for sorting with accented characters
Version 2.28
Added SetHeaderTypeFaces
Added SortRemoveAccents property
Version 2.29
Added SaveTableToCSV2 with a user defined separator character

EDIT: 2018.04.11 Version 2.26
added LoadSQLiteDB3 method using SQLExec2 instead of SQLExec
The query can include question marks which will be replaced with the values in the array.

EDIT: 2018.03.27 Version 2.25
amended minor errors
added UpdateCell method

EDIT: 2017.11.19 Version 2.22
improved JumpToRowAndSelect scrolls horizontally to the selected column
improved setHeaderHeight
added padding for status bar Label

EDIT: 2017.06.27 Version 2.19
Replaced DoEvents by Sleep(0)
Asked HERE

EDIT: 2017.06.27 Version 2.19
Replaced DoEvents by Sleep(0)
Asked HERE

EDIT: 2017.05.16 Version 2.18
Amended error reported HERE.

EDIT: 2017.03.09 Version 2.17
Amended error reported HERE.

EDIT: 2017.03.09 Version 2.15
Amended error reported here, Event signatures
#Event: CellClick(col As Int, row As Int)
#Event: CellLongClick(col As Int, row As Int)

EDIT: 2016.12.05 Version 2.14
Added NumberOfColumns and NumberOfRows as Public variables.
Amended error reported here.

EDIT: 2016.12.05 Version 2.13
Amended error reported here.
Added NumberOfColumns as a property for the Designer.

EDIT: 2016.07.30 Version 2.10
Amended error with TextAlignment and HeaderTextAlignment reported in post #606

EDIT: 2016.03.15 Version 2.00
Added CustomView support.
This version can be compiled into a library.
Changes between the previous versions and version 2.00
For a Table added in the Designer, this is new
No need to initialize nor add it onto a parent view
'For a Table added in the Designer, this is new
'No need to initialize nor add it onto a parent view

For a Table added in the code:
The Initialize routine has been splittend into two routines.
New:
Initialize (CallBack As Object, EventName As String)
InitializeTable (vNumberOfColumns As Int, cellAlignement As Int, showStatusL As Boolean)

'Example:
Table1.Initialize(Me, "Table1")
Table1.InitializeTable(5, Gravity.CENTER_HORIZONTAL, True)


Old:
Initialize(CallBack As Object, EventName As String, vNumberOfColumns As Int, cellAlignement As Int, showStatusL As Boolean)
Example:
Table1.Initialize(Me, "Table1", 5, Gravity.CENTER_HORIZONTAL, True)

EDIT: 2015.04.29 Version 1.43
As the modifications in LoadSQLiteDB don't work in all cases I went back.
LoadSQLiteDB as in version 1.40
Added LoadSQLiteDB2 where the column data types must be given.

EDIT: 2015.04.26 Version 1.42
Changed he LoadSQLiteDB routine, version 1.41 didn't work as expected.
The final solution was suggested by cimperia HERE.

EDIT: 2015.04.16 Version 1.41
Changed the LoadSQLiteDB routine according to the error reported in the SQL issue thread
and the SQLite Cursor GetString versus GetDouble thread.
The problem appears with numbers bigger than 999999.
I left version 1.40 in case of problems.
I tested it with a few databases, but I am not sure if it works in all cases.

EDIT: 2015.03.05
Amended bugs reported in posts #383 and #386
Added SetAutomaticWidths routine

EDIT: 2015.02.19
Amended the problem alignment reported in post # 378

EDIT: 2015.02.13
Amended the problem of rows not shown reported in post # 371

EDIT: 2015.01.09
Added header aligments

EDIT: 2014.08.14
Added HeaderHeight property
Amended RowColor problem reported in post #260

EDIT: 2014.08.10
Added SortColumn property asked in post #266
Added UseColumnColors ColumnColors and HeaderColors propeties

EDIT: 2014.05.10 Added RowHeight as a property

Screenshot:

1589638570453.png
 

Attachments

  • TableV1_44.zip
    44.8 KB · Views: 2,183
  • 1589638550715.png
    1589638550715.png
    31.8 KB · Views: 1,611
  • TestFastScroll.zip
    50.6 KB · Views: 1,458
  • TableV3_35.zip
    110 KB · Views: 269
  • Table.bas
    152.2 KB · Views: 196
Last edited:

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
    ex1.jpg
    191.3 KB · Views: 202
  • ex2.jpg
    ex2.jpg
    178.7 KB · Views: 224
  • Test Table.zip
    9.7 KB · Views: 212

RB Smissaert

Well-Known Member
Licensed User
Longtime User
This thread will be used by Erel, Melamoud and myself to discuss / post new releases of the Table class.

The table class is a flexible UI component that enable scrollable table like UI, with sortable columns, multiselect rows etc

the table is very efficient, maintaining labels only for visible rows

old thread with details : http://www.b4x.com/forum/additional...view-supports-tables-any-size.html#post110901

The class depend on following libraries:
- StringUtils (standard)
- SQL (standard)
- JavaObject (standard)
- ScrollView2D (additional)

List of major features.
1. scrollable table UI
2. sortable columns
3. select a row, cell or multi select rows
4. callback for selection / click a cell / row
5. callback for long click action
6. read / write to CSV file

Current version --> 3.30 Custom View
Current version --> 1.44 Class

Other complementary routines:

Load data with the Remote Database Connector.


EDIT: LucaMs has written a routine to fill a table with a Remote Database Connector query result see post 182.
The routine hasn't been added into the Class for the reasons explained in post 183.
A sample program can be found HERE.

Code:
B4X:
'load data from a RDC Request
'Result = DBResult object got from a RDC request
'AutomaticWidths  True > set the column widths automaticaly
'Written by LucasMs
Public Sub LoadRDCResult(Result As DBResult, AutomaticWidths As Boolean)
    cAutomaticWidths = AutomaticWidths
    NumberOfColumns = Result.Columns.Size
    innerClearAll(NumberOfColumns)

    Dim Headers(NumberOfColumns) As String
    Dim ColumnWidths(NumberOfColumns) As Int
    Dim HeaderWidths(NumberOfColumns) As Int
    Dim DataWidths(NumberOfColumns) As Int
    Dim col, row As Int
    Dim str As String
    For col = 0 To NumberOfColumns - 1
        Headers(col) = Result.Columns.GetKeyAt(col)
        If AutomaticWidths = False Then
            ColumnWidths(col) = 130dip
            HeaderWidths(col) = 130dip
            DataWidths(col) = 130dip
        Else
            HeaderWidths(col) = cvs.MeasureStringWidth(Headers(col), Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth
            DataWidths(col) = 0

            Dim FieldValue As Object
            For row = 0 To Result.Rows.Size - 1
                Dim Record() As Object = Result.Rows.Get(row)
                FieldValue = Record(col)
                If GetType(FieldValue) = "java.lang.String" Then
                    DataWidths(col) = Max(DataWidths(col), cvs.MeasureStringWidth(str, Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth)
                End If
            Next
            ColumnWidths(col) = Max(HeaderWidths(col), DataWidths(col))
        End If
    Next
    SetHeader(Headers)
    SetColumnsWidths(ColumnWidths)

    For Each Record() As Object In Result.Rows
        Dim R(NumberOfColumns) As String
        Dim FieldV As String
        For col = 0 To NumberOfColumns - 1
            FieldV = Record(col)
            R(col) = FieldV
        Next
        AddRow(R)
    Next
End Sub

This is another routine updated by cimperia in post #392 using a Map for the columns and a List for the rows.
B4X:
'load data from a RDC Request
'A RDC request returns a DBResult object, therefore this method
'could be called as is:
'LoadRDCResult(DBResult.Columns, DBResult.Rows, True)
'AutomaticWidths  True > set the column widths automaticaly
'Written by LucasMs
Public Sub LoadRDCResult(Columns As Map, Rows As List, AutomaticWidths As Boolean)
  cAutomaticWidths = AutomaticWidths
  NumberOfColumns = Columns.Size
  innerClearAll(NumberOfColumns)

  Dim Headers(NumberOfColumns) As String
  Dim ColumnWidths(NumberOfColumns) As Int
  Dim HeaderWidths(NumberOfColumns) As Int
  Dim DataWidths(NumberOfColumns) As Int
  Dim col, row As Int
  Dim str As String
  For col = 0 To NumberOfColumns - 1
    Headers(col) = Columns.GetKeyAt(col)
    If AutomaticWidths = False Then
      ColumnWidths(col) = 130dip
      HeaderWidths(col) = 130dip
      DataWidths(col) = 130dip
    Else
      HeaderWidths(col) = cvs.MeasureStringWidth(Headers(col), Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth
      DataWidths(col) = 0

      Dim FieldValue As Object
      For row = 0 To Rows.Size - 1
        Dim Record() As Object = Rows.Get(row)
        FieldValue = Record(col)
       If GetType(FieldValue) = "java.lang.String" Then
         DataWidths(col) = Max(DataWidths(col), cvs.MeasureStringWidth(str, Typeface.DEFAULT, cTextSize) + 8dip + cLineWidth)
       End If
      Next
      ColumnWidths(col) = Max(HeaderWidths(col), DataWidths(col))
    End If
  Next
  SetHeader(Headers)
  SetColumnsWidths(ColumnWidths)

  For Each Record() As Object In Rows
    Dim R(NumberOfColumns) As String
    Dim FieldV As String
    For col = 0 To NumberOfColumns - 1
      FieldV = Record(col)
      R(col) = FieldV
    Next
    AddRow(R)
  Next
End Sub


Load data from a MSMariaDB database.

Another routine for loading data from a MSMariaDB database can be found in post#727.
Thanks to @Magma.

Updates:
EDIT: 2021.06.28 Version 3.30
Added a check for none numeric values for numeric sorting.

EDIT: 2021.06.28 Version 3.29
Amended problem with column colors
Version 3.28
Added NumberOfColumns in the code
Added TopRowIndex method
Version 3.27
Amended MultiSelect EDIT: 2020.09.02 Version 3.26
Amended problem with sort with remove accents
Amended problem with SetRowColorN
Added SetCellAlignmentColN method
Added SetHeaderAlignmentColN method

EDIT: 2020.08.05 Version 3.24
Amended problem with JumpToRowAndSelect not being selected.
Amended error when setting RowHeight before the table initialized

EDIT: 2020.06.19 Version 3.22
Amended error in the insertRowAt routine.

EDIT: 2020.05.25 Version 3.21
Amended bug with TextSize in fixed columns

EDIT: 2020.05.16 Version 3.20
Added fast scroll feature
Version 3.19
Improved automatic width calculation and hidden columns
Version 3.18
Added a check in RemoveRowColorN to ensure that Row is not out of bounds
Added ShowRow event
Amended automatic width calculations
Amended hidden column width problem

EDIT: 2020.04.21 Version 3.17
Amended HeaderHight problem with fixed columns

EDIT: 2020.04.21 Version 3.16
Amended two errors.

EDIT: 2020.04.14 Version 3.14
Added the methods below
- LoadSQLiteDB4(SQLite As SQL, Query As String, AutomaticWidths As Boolean)
loads SQLite data with data type checking
- LoadSQLiteDB5(SQLite As SQL, Query As String, Values() As String, AutomaticWidths As Boolean).
loads SQLite data with data type checking , similar to LoadSQLiteDB4 but for parametrized queries.
- GetColumnDataTypes As String(), returns an Array with the data type for each column.
- GetColumnDataType(Column As Int) As String, returns the data type of the fiven column.
Added the InnerTotalWidth property, read only.
Added multiple first fiexed columns
Added line colors

EDIT: 2020.03.10 Version 3.10
Amended bug reported HERE

EDIT: 2020.03.06 Version 3.09
Amended bug reported HERE.

EDIT: 2020.02.29 Version 3.08
Amended SetHeaderTypefaces method problem reprted HERE.
Added HeaderTypeface property.

EDIT: 2020.01.08 Version 3.07
Amended bug ShowStatisLine = False property bug.
Added MultiSelect property to Designer properties.
You need to open and close the Designer when you use the new version the first time to make the MultiSelect property active.

EDIT: 2019.12.28 Version 3.06
Amened some bugs

EDIT: 2019.12.25 Version 3.05
Added FirstColumnFixed property which allows to fix the first column.
Attention: You need to open and close the Designer to make the new property active.

EDIT: 2019.11.15 Version 3.04
- Added SelectedRowTextColor and SlectedCellTextColor properties
- Added ZeroSelections property, True > when a selected row is pressed it will be unselected False > it remains selected.

EDIT: 2019.11.12 Version 3.03
- Changed JumpToRowAndSelect(Row As Int, Col As Int) to JumpToRowAndSelect(Col As Int, Row As Int)
- Changed LoadSQLiteDB2 signature. Replaced the possible values from "T", "I", "R" to "TEXT", "NUMBER" for coherence with SetColumnDataTypes.
- Added internal sorting bitmaps, avoids loading the image files into the Files folder.
- Added two new properties: SortBitmapWidth and SortBitmapColor.
- Added SetCustomSortingBitmaps method, which allows to use custom bitmaps instead of the internal ones.
Attention: You need to open and close the Designer to make the new properties active.
Attention: You need to invert the parameters in JumpToRowAndSelect.

EDIT: 2019.07.04 Version 3.02
Amended error reported in post #887

EDIT: 2019.06.26 Version 3.01
Amended SingleLine property setting in the code

EDIT: 2019.04.05 Version 3.00
Amended SetColumnColors and SetTextColors
Removed Reflection library dependency

EDIT: 2018.04.11 Version 2.29
Version 2.27
set the two variables sortedCol and sortingDir to Public instaed of Private
added RemoveAccent routine for sorting with accented characters
Version 2.28
Added SetHeaderTypeFaces
Added SortRemoveAccents property
Version 2.29
Added SaveTableToCSV2 with a user defined separator character

EDIT: 2018.04.11 Version 2.26
added LoadSQLiteDB3 method using SQLExec2 instead of SQLExec
The query can include question marks which will be replaced with the values in the array.

EDIT: 2018.03.27 Version 2.25
amended minor errors
added UpdateCell method

EDIT: 2017.11.19 Version 2.22
improved JumpToRowAndSelect scrolls horizontally to the selected column
improved setHeaderHeight
added padding for status bar Label

EDIT: 2017.06.27 Version 2.19
Replaced DoEvents by Sleep(0)
Asked HERE

EDIT: 2017.06.27 Version 2.19
Replaced DoEvents by Sleep(0)
Asked HERE

EDIT: 2017.05.16 Version 2.18
Amended error reported HERE.

EDIT: 2017.03.09 Version 2.17
Amended error reported HERE.

EDIT: 2017.03.09 Version 2.15
Amended error reported here, Event signatures
#Event: CellClick(col As Int, row As Int)
#Event: CellLongClick(col As Int, row As Int)

EDIT: 2016.12.05 Version 2.14
Added NumberOfColumns and NumberOfRows as Public variables.
Amended error reported here.

EDIT: 2016.12.05 Version 2.13
Amended error reported here.
Added NumberOfColumns as a property for the Designer.

EDIT: 2016.07.30 Version 2.10
Amended error with TextAlignment and HeaderTextAlignment reported in post #606

EDIT: 2016.03.15 Version 2.00
Added CustomView support.
This version can be compiled into a library.
Changes between the previous versions and version 2.00
For a Table added in the Designer, this is new
No need to initialize nor add it onto a parent view
'For a Table added in the Designer, this is new
'No need to initialize nor add it onto a parent view

For a Table added in the code:
The Initialize routine has been splittend into two routines.
New:
Initialize (CallBack As Object, EventName As String)
InitializeTable (vNumberOfColumns As Int, cellAlignement As Int, showStatusL As Boolean)

'Example:
Table1.Initialize(Me, "Table1")
Table1.InitializeTable(5, Gravity.CENTER_HORIZONTAL, True)


Old:
Initialize(CallBack As Object, EventName As String, vNumberOfColumns As Int, cellAlignement As Int, showStatusL As Boolean)
Example:
Table1.Initialize(Me, "Table1", 5, Gravity.CENTER_HORIZONTAL, True)

EDIT: 2015.04.29 Version 1.43
As the modifications in LoadSQLiteDB don't work in all cases I went back.
LoadSQLiteDB as in version 1.40
Added LoadSQLiteDB2 where the column data types must be given.

EDIT: 2015.04.26 Version 1.42
Changed he LoadSQLiteDB routine, version 1.41 didn't work as expected.
The final solution was suggested by cimperia HERE.

EDIT: 2015.04.16 Version 1.41
Changed the LoadSQLiteDB routine according to the error reported in the SQL issue thread
and the SQLite Cursor GetString versus GetDouble thread.
The problem appears with numbers bigger than 999999.
I left version 1.40 in case of problems.
I tested it with a few databases, but I am not sure if it works in all cases.

EDIT: 2015.03.05
Amended bugs reported in posts #383 and #386
Added SetAutomaticWidths routine

EDIT: 2015.02.19
Amended the problem alignment reported in post # 378

EDIT: 2015.02.13
Amended the problem of rows not shown reported in post # 371

EDIT: 2015.01.09
Added header aligments

EDIT: 2014.08.14
Added HeaderHeight property
Amended RowColor problem reported in post #260

EDIT: 2014.08.10
Added SortColumn property asked in post #266
Added UseColumnColors ColumnColors and HeaderColors propeties

EDIT: 2014.05.10 Added RowHeight as a property

Screenshot:

View attachment 94167
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
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.
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:

1692019238587.png
 

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.

1692045770020.png

B4X:
 

fishwolf

Well-Known Member
Licensed User
Longtime User
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.

View attachment 144785
B4X:
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
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
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
 
Top