B4A Library [Class] Flexible Table

klaus

Expert
Licensed User
Longtime User
I want to propose, on your wonderful table class, to add the ability to sum the numeric columns, putting a footer panel as the header panel.
I'm afraid that this is too specialized and will make the class to complicated.
 

Bryan

Member
Licensed User
Longtime User
There is no column width changed event.
Column colors can be set since version 1.36.

Yes, LoadTableFromCSV2 has as the last parameter AutomaticWidths, set it to true.

I've been trying to make my table look good on different devices so I tried using AutomaticWidths which works very well. The only issue I have is the table or Scrollview itself as a whole. What would be the best way if possible to automatically center table horizontally and have the table width resize to the combined widths of my columns. I only use 4 columns in my table. So, my table does not need to be the entire width of my activity. Especially in landscape orientation if used on a tablet. It looks kind of odd if my table is stretched out to fill the screen and my first column is at 0 top and 0 left leaving half the screen blank or showing the unfilled portion of the scrollview that does not contain any columns. This is where I think it would look better if I could resize and center the table along with using AutomaticWidths for columns.

Thanks, Bryan
 

Bryan

Member
Licensed User
Longtime User
You can place the whole table whereever you want or need, but you must to do it in your code.
You can read the inner width with Table1.HeaderPanel.Width.
You can then reset the Left, Top, Width and Height properties.

This works very good now for keeping my table centered. There is another problem to resolve after this. If a row is added or removed from the table then somehow the table needs to be refreshed so the column widths can adjust to any text changes that might have occurred. Is there another way to do this other then reloading the table again from my csv file?

Thanks
 

mat2175

Member
Licensed User
Longtime User
Hi Klaus, is there a way to deselect a row. I tried the code below but cant get it to work.

Thanks

B4X:
Dim rc as RowCol
rc.Row = -1
Table1.SelectRow(rc)
 

klaus

Expert
Licensed User
Longtime User
Sorry for answering only today, but I was on travel since Sunday.
The original Table doesn't allow to unselect a row.
In the Class subroutine SelectRow comment the Return line like below, then you can unselect a row.
B4X:
Public Sub SelectRow(rc As RowCol)
    Dim prevIndex As Int
    Dim prev As Int ' if we select an alreday selected row, prev will be rc.row, else will be -1
   
    prevIndex = SelectedRows.indexof(rc.Row)     ' -1 if selecting not a selected row   
    If (prevIndex <> -1 AND IsMultiSelect = False) Then
        ' if IsMultiSelect = True no column change, only if IsMultiSelect = False
        SelectedCol = rc.col
        If visibleRows.ContainsKey(rc.Row) Then
            HideRow(rc.Row)
            ShowRow(rc.Row)
        End If
'        Return
    End If
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Great class. I was looking at it late last night, got my tabled filled using sub filltable from example v1_30.
Just wondering why it's called in activity resume? I've got a menu option, that is going bring up this table with the current (refreshed) results.

The example in table v1_30, doesn't refresh the results. I'll take a look at it again.
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Hmm, yes I've got the latest class but I was looking at an old example in the thread.

Basically want to fill a table with a query, and refresh its result (when I bring it up again). I believe it said the db was already opened or re-opened.
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Ok, I see in your example in v1_36 you FillTableSQLite on activity create, v1_30 had it in activity resume.

I'll move it, and add a refresh button to reload the table (clear & rerun the FillTableSQLite )
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Ok, I solved the problem. I was closing the db connection after inserting records into it.
Just removed that, and it works without any problems...( I can rerun that query, and fill in the table...)


java.lang.IllegalStateException: attempt to re-open an already-closed object: SQLiteDatabase: /storage/emulated/0/Android/data/solarble.com/files/solarlog.db
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Greetings, all, and Hello, Klaus.

I use this class quite frequently both with csv files and SQLite tables - great work for Erel and Klaus. Thank you, both.

Question:
I just starting using RDC. Is there an easy way to get the results from the command in RDC into the table? (like Sub LoadSQLiteDB)?


Any and all help is welcomed.

Sandy
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Hello, Klaus.

I do not know how I could have possibly missed it! It could not possibly be more obvious. I wish I could take my question back! I just started using RDC a few days ago.

I use your class QUITE frequently, and once again, I express my gratitude for your brilliant and comprehensive work.

Best regards.

Sandy
 

Stolli0815

Member
Licensed User
Longtime User
Hello Klaus.


Great job, Thanks!

Is there a posibility to keep column 0 fixed, as the Header is?
Currently I programmed with show/hide column the functionality. But unfortunatelly the internal ScrollView2D object consumes the "scroll - events" of the underlaying panel, so I can't react on the touch event of the panel.

I added to SV_ScrollChanged the Callback
If SubExists(Callback, Event & "_TableScroll") Then
CallSub3(Callback, Event & "_TableScroll", PosX, PosY)
End If

That enables me to react on the Scroll - Event from the Main Application.

Maybe a good idea to add this as an additional functionality. (Feel free)

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