B4A Library [Class] Flexible Table

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I said I could see no difference with other flexible tables in my app, but there is one difference:
This is a B4XPages project with about 30 flexible tables.
There are 3 pages with a flexible table where the page is created on startup of the app.
The layout (so also the flexible table) is loaded in the Sub B4XPage_Created:

B4X:
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.Tag = iPageCode 'so we can see in clsMenu we are getting the right root
    Load_Layout
End Sub

Of these 3 flexible tables on these 3 pages there are 2 that show the mentioned problem.

I have done some logging of the flexible table class, to do with the Sub innerClearAll and that shows the following logs on startup of the app:

DesignerCreateView, Table name: tblSavedSQL
InitTable, called by: DesignerCreateView
innerClearAll, called by: InitTable
DesignerCreateView, Table name: tblSQLResult
InitTable, called by: DesignerCreateView
innerClearAll, called by: InitTable
DesignerCreateView, Table name: tblDBBrowser
InitTable, called by: DesignerCreateView
innerClearAll, called by: InitTable

Now the tables that show the mentioned problem are tblSQLResult and tblDBBrowser. No other tables show the mentioned problem.

Apart from the way the way B4XPage, (holding the flexible) is started there is no difference with all the other flexible tables.
So, I am guessing the mentioned problem has to do with the way the page is started, except tblSavedSQL doesn't show the mentioned
problem.

Still seen no problem yet with commenting out:

B4X:
SVF.ScrollPosition = 0

In innerClearAll in the flexible table class.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I managed to make a test project that shows this problem.
Note that this is using the Table custom view, without any alterations.
Attached the zipped project.

To show the problem compile the app and press the fifth item (the +-) on the menubar and do a scroll down (finger going up).
Note that if you scroll again it won't go back to row 1 as mentioned before.

RBS
I managed to make a test project that shows this problem.
Note that this is using the Table custom view, without any alterations.
Attached the zipped project.

To show the problem compile the app and press the fifth item (the +-) on the menubar and do a scroll down (finger going up).
Note that if you scroll again it won't go back to row 1 as mentioned before.

RBS
 

Attachments

  • Project.zip
    230.3 KB · Views: 132

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Two things to do with this:
1. The mentioned problem doesn't seem to be happening in Debug mode.
2. I noticed sorting the table is still very slow with the selection sort, so uploaded a new project with faster table sorting.

RBS
 

Attachments

  • Project2.zip
    235.7 KB · Views: 121

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Two things to do with this:
1. The mentioned problem doesn't seem to be happening in Debug mode.
2. I noticed sorting the table is still very slow with the selection sort, so uploaded a new project with faster table sorting.

RBS
Some other additions:
1. Allowing non UTF-8 .csv files to be imported
2. Having the option to skip columns in the .csv file to be imported
3. Speeding up the column width measurement

The third icon on the menubar does the original Sub LoadTableFromCSV2 (but with the increased sorting speed)
The fourth icon on the menubar does a new Sub LoadTableFromCSV3 having options 1, 2 and 3 but imports a UTF-8 file
The fifth icon on the menubar imports a windows-1252 file and skips 4 columns

Also added a timer to making this easier to log.
The described scrolling bug will still show.

RBS
 

Attachments

  • Project3.zip
    250.1 KB · Views: 137

klaus

Expert
Licensed User
Longtime User
To amend the scrolling back to the first row is solved by this in the SV2_ScrollChanged routine.
Move the SVF.ScrollToNow(PosY) line just after If SVFScrolls = False Then

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

I had also seen the problem with grey cells, but I have never found why this does happen.
 

klaus

Expert
Licensed User
Longtime User
I made some further investigations with the scrolling problem.
The problem appears when FastScroll is activated and the table is relatively long.
It seems that the program cannot update the cells fast enough when the user scrolls fast.
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Thanks, will change that and let you know if there still is a problem.
Any chance you could incorporate the altered table sorting code?
It doesn't seem a major change and it will definitely be useful to have a much faster sort.

RBS
 

klaus

Expert
Licensed User
Longtime User
I had a look at the new sorting code.
Sorry, but I will not add those because:
It needs three more libraries: B4XPages, RandomAccessFile and Reflection
It needs two more classes.
It will increase the code size by 30%.
Currently it must be a B4XPages project.
This could probably be avoided by moving the GetCharacterEncodingFromFile routine to the Table module.
And removing the two variables bMultiColumnSort and bSortTableCaseInsensitive in the B4XMainPage and add those as properties to the Table module.
Currently there is one Type declaration in the Enum module and to avoid adding also this module, the declaration should be moved somewhere else.
Then, you might have trouble with a double Type declaration.

I do not know if many users use the sorting and how many out of them need a quick sorting.
And all the others do not need these additional libraries and classes and code.
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
It doesn't need to increase the code size by 30%.
It also doesn't need those 3 added libraries. They were just added to my demo project to demonstrate the mentioned scrolling bug to make it
all look like my big main project.
The whole Enums module is not needed either.
bMultiColumnSort and bSortTableCaseInsensitive can be left out as well.

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.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Would be interesting.
Downloaded TableV3_33 from the original Flexible Table posting and made the alterations to the Table class and also to Main.
I then zipped the modules Main and Table and attached that as a .zip.
All the added code is marked as: RBS, Added.
The only library to be added extra is B4XCollections as that is used in the sorting code.
Have tested it and it seems to work all fine.
Note that the first table in Main (people) will sort properly as the datatypes are added, but the second table (Cities) don't sort properly
as all the columns have the data type T.
Multi-column sort and case-insensitive sort are both False by default.

RBS
 

Attachments

  • TableV3_33.zip
    31.1 KB · Views: 119

fishwolf

Well-Known Member
Licensed User
Longtime User
If in example 3.33 version i set
B4X:
Table1.TableColor = 0x00ffffff
for a trasperent table
and set the "First columns fixed"

line of header fixex columns are dirtied by other columns

 

klaus

Expert
Licensed User
Longtime User
This is because of the transparent color.
When you scroll the other columns to the left, the header of these columns moves to the left behind the header of the fixed columns and you see the header of these columns in the lines of the fixed columns header.
Why do you want to set the TableColor to transparent ?
 

fishwolf

Well-Known Member
Licensed User
Longtime User
iit is a requirement for a more modern interface

i write here because the problem is not showed in line of table, only in header

i have attach screenshot and example

 

Attachments

  • ExampleE.zip
    63.8 KB · Views: 93

klaus

Expert
Licensed User
Longtime User
i write here because the problem is not showed in line of table, only in header
I knew this, I explained you why this happens.
Try the added project.
I had to add a Panel for the Header to limit its visibility, which was 'normally' hidden by the Header of the fixed columns.
 

Attachments

  • Table1.zip
    63.9 KB · Views: 84
Cookies are required to use this site. You must accept them to continue using the site. Learn more…