B4A Library [Class] TableView - Supports tables of any size

An improved version of this class is available here: http://www.b4x.com/forum/additional...icial-updates/30649-class-flexible-table.html


The Table class allows you to show tables of any sizes. The views (labels) are reused to avoid creating many views.

With the help of StringUtils the table can be loaded and saved to a CSV file. It shouldn't be difficult to show SQL tables using DBUtils.ExecuteMemoryTable.

SS-2012-07-04_10.38.01.png


Follow the attached example to see how the class is used. To add it to your own project you need to add the class module to your project and add a reference to StringUtils library.

RemoveRow code is available here: http://www.b4x.com/forum/showpost.php?p=146795&postcount=147

V1.10 uploaded. New method: SetColumnsWidths. Allows you to manually set the width of each column
V1.11 uploaded. Fixes a bug with grey stripes appearing.
 

Attachments

  • Table.zip
    14.9 KB · Views: 7,925
Last edited:

androb

Member
Licensed User
Longtime User
Hello,

This looks really good. Thank you for your efforts. Is it possible to change the height of the header row? I have long column labels that are cut off.
 

androb

Member
Licensed User
Longtime User
Please can you explain how I might use this..I get an error when trying:

TableFC.HeaderHeight =100dip

I am trying to use the table fixed column example, and there is no property/method headerheight in Table class...?
 

little3399

Active Member
Licensed User
Longtime User
Hi

Does this class can be add a function , when the cell_click can be update the cell content, just like the excel edit function ?o_O
 

solfinker

Member
Licensed User
Longtime User
Hello.
I get the following error when trying to compile
"Unknown member": add
line 151: Data.Add(Values)

in the Table class

I am using the following libraries:
Core 4.01
SS_SlidingMenuStandard 1.34
StringUtils 1.02


and two activity modules - plus the table class.

In another app without the SS_SlidingMenuStandard library it works smoothly.

Thank you very much for your help.

P.S. Keep in mind that my programming skills are LL (low-low)
 

klaus

Expert
Licensed User
Longtime User
Sorry, but without seeing your code, therefore not knowing what you have done and how it's impossible to give you a concrete advice.
Example:
Data.Add(Values), what is Data ?
The Table classe doesn't have an Add method !?

Post a small project showing the problem, with an explanation of what exactly you want,.

What Table class version do you use ? The latest version 1.43 is HERE.
 

solfinker

Member
Licensed User
Longtime User
I am using Table class version 1.11. But the same error appears with version 1.43 (line 454).
Here is the table class 1.11

The only difference I can see between my application and the examples is the existence of two activity modules.

Just in case you want to try, hereunder:
 

Attachments

  • appnotcompiling.zip
    27.3 KB · Views: 264

solfinker

Member
Licensed User
Longtime User
Now it works!
Thank you.
The only thing - I think - I have changed is the name of the 2nd activity: from "Data" to "ActivityData".
 

solfinker

Member
Licensed User
Longtime User
Can I use the table - meaning the data from the csv - without showing the table in the layout?
I know the following code works
B4X:
Table1.AddToActivity(Activity, 0, 100%y, 0, 0)
but I am not sure if it is correct, and if it would give me problems.

Thanks for your advice.

I'm using table class version 1.11
 

solfinker

Member
Licensed User
Longtime User
This is what I am using the table for:
B4X:
Private Sub CreateBarChartData (cols As List, rows As List)
    cols.Add(CreateColumn("", "Time", "string"))
    cols.Add(CreateColumn("", "x1", "number"))
    cols.Add(CreateColumn("", "y1", "number"))
    rows.Add(CreateRow(Array As Object(Table1.GetValue(0,11), Table1.GetValue(1,11), Table1.GetValue(2,11))))
    rows.Add(CreateRow(Array As Object(Table1.GetValue(0,12), Table1.GetValue(1,12), Table1.GetValue(2,12))))
    rows.Add(CreateRow(Array As Object(Table1.GetValue(0,13), Table1.GetValue(1,13), Table1.GetValue(2,13))))
End Sub

I do not need to show the table in my layout. I just need to pick the data from the csv, and that is why I am using the table for. But I can't get the data without
B4X:
Dim Table1 As Table
Table1.Initialize(Me, "Table1", 0)
Table1.AddToActivity(Activity, 0, 100%y, 0, 0)
Table1.LoadTableFromCSV(File.DirRootExternal, "cs/last.txt", True)
can I? Am I using a sledgehammer to crack a nut?

Thank you for your advise.
 

solfinker

Member
Licensed User
Longtime User
Thank you. I'm going to try it.
I am showing the table in another module - same app - but not in this one.
 

solfinker

Member
Licensed User
Longtime User
I have made some search, and I have not find any tutorial about StringUtils.LoadCSV, although I suppose I have to use a List, something similar to the following which is not working:
B4X:
Dim Table1 As List
Dim su As StringUtils
Dim rc As RowCol
Table1 = su.LoadCSV(File.DirRootExternal, "cs/last.txt", ",")
rc.Initialize
rc.Row = 0 : rc.Col = 1
Log("(0,1) " & Table1.Get(rc))
rc.Row = 0 : rc.Col = 2
Log("(0,2) " & Table1.Get(rc))

Any help about finding a tutorial would be apreciated.
Thank you very much for your patience.
 

solfinker

Member
Licensed User
Longtime User
Thank you.
I suppose I'll keep up with the table class.
 
Top