B4A Library [Class] Flexible Table

Mike Olmsted

Member
Licensed User
More......
I liken the problem to where you cannot edit under the space that a table has allocated.
There is a gray line there that stops me from selecting Wages. My Google Nexus 7 is the new one
with the HD display.
 

klaus

Expert
Licensed User
The problem only occurs when the table exceeds one page. Try to select Wages on page 2 of the table.
Sorry, but I don't understand what you mean with page 1 and page 2 ?
I tested the project you posted in post #18 and it works OK on my Nexus One.

Best regards.
 
Last edited:

shashkiranr

Active Member
Licensed User
Hi,

1. How was Db created in the example. I am using SQLite Studio to create a db but i am getting an error "Table not found" when i load the db into the table.

2. I copied the table details into a CSV and tried to load it. The Column headers are getting loaded properly but the values is not getting loaded at all.
I called
B4X:
Table1.LoadTableFromCSV(File.DirAssets,"testdummy.csv",True)
to load from CSV.

3. Is it possible to use MySqL dump like
B4X:
dummytest.sql
Kindly let me know your inputs and suggestions.

Regards,
SK
 

Mike Olmsted

Member
Licensed User
Here is how to do it with the least lines of code.
B4X:
    pnlTable.Initialize("")
    Activity.AddView(pnlTable, 0dip, 40dip, 100%x , 80%y ) 
    table1.Initialize(Me, "Table1", 11, 1, True)
    table1.AddToActivity(pnlTable, 0, 0, pnlTable.Width, pnlTable.Height)     

    query = "SELECT * from tblNameAddress ORDER BY NameorCompany"       
    table1.loadsqlitedb(Main.SQL1,query,True)
    table1.SetColumnsWidths(Array As Int(50dip,160dip,100dip,100dip,0dip, 100dip,100dip, 180dip, 120dip, 60dip, 60dip))
If you don't need the panel you can save two lines.....Mike
 

AubreyPCR

Member
Licensed User
Could you post a screenshot.
On my Nexus One it works OK.
Try to replace the height of the table in this line:
Activity.AddView(pnlTable, 0dip, 0dip, 100%x , 90%y )

Best regards.

Klaus,
I have the same problem on my S4. It is almost impossible to select the last row in the table.
My panel size is set by a designer script at layout load time and then I use the code
B4X:
tblData.AddToActivity(pnlTable, 0, 0, pnlTable.Width, pnlTable.Height)
to add the table.
I tried
B4X:
tblData.AddToActivity(pnlTable, 0, 0, pnlTable.Width, (pnlTable.Height/100)*90)
and this seemed to cure the selection problem. It left part of its internal panel visble which sort of ruined the look and wasted screen space so its not an ideal solution. Would it be possible to have a look at why this might be happening and maybe propose a different solution.
I am using table V1.24. Thank you as ever for sharing your code.
Regards,
 

Attachments

klaus

Expert
Licensed User
@shashkiranr
I am answering only today, I was on travel the last four days and came back today at noon.
1) The persons.db was created in an Excel csv file and converted into a db with a Basic4PPC program.
2) I don't know why this happens, could you post your project as a zip file and I'll have a look at it (IDE menu Files / Export As Zip).
3) No.

Best regards.
 

klaus

Expert
Licensed User
@Mike Olmsted
If you use this line:
table1.LoadSQLiteDB(Main.SQL1,query,True)
you don't need this one
table1.SetColumnsWidths(Array As Int(50dip,160dip,100dip, ...
because the True parameter in LoadSQLiteDB means automatic column widths, the program calculates the widht of the longuest entry in each column to determine its width.

If you want to define the widths yourself use
table1.loadsqlitedb(Main.SQL1,query,False)
table1.SetColumnsWidths(Array As Int(50dip,160dip,100dip,...

This will be faster, no column width calculation.

Best regards.
 

klaus

Expert
Licensed User
@AubreyPCR
Could you post your project as a zip file (IDE menu Files / Export As Zip).
Without seeing what exactly you have done in your code it's almost impossible to give a concrete advice.
I have never encountered a case where the last line was not visible.

Best regards.
 

AubreyPCR

Member
Licensed User
@AubreyPCR
Could you post your project as a zip file (IDE menu Files / Export As Zip).
Without seeing what exactly you have done in your code it's almost impossible to give a concrete advice.
I have never encountered a case where the last line was not visible.

Best regards.
Klaus, thanks for responding.
Just to clarify. When I use the table "as is" I have a problem selecting the last visible row in a table (same as Mike Olmstead). Its as if the area capturing the touch event did not extend all the way to the bottom of the table. So I tried your advice about reducing the size by 10% which resulted in the image I posted. I'll try to post the code later.

Regards.
 

duneplodder

Active Member
Licensed User
I use this table class in one of my projects. Thank you for making it available.
It is used mainly to present numeric data. I would like to highlight certain cells e.g. where the value is over 10.
Would it be possible to change the color of individual cells at a specific row/column? I haven't done much with classes and can't see how this could be achieved.
Regards,
Robert
 

shashkiranr

Active Member
Licensed User
I am answering only today, I was on travel the last four days and came back today at noon.
1) The persons.db was created in an Excel csv file and converted into a db with a Basic4PPC program.
2) I don't know why this happens, could you post your project as a zip file and I'll have a look at it (IDE menu Files / Export As Zip).
3) No.
Hi Kluas,

Sorry for the delayed reply.

1. I am using Sql Studio. it creates Database in DBF format and not .db format. Is there any other way which i can use to create .db files?
IF yes kindly let me know

2. I have attached the sample project which is same as tableV1_24. Only thing is i am loading the contents using LoadTableFromCSV method.
Kindly let me know the mistake i am making. Is it possible to give an example to using the LoadTableFromCSV. It would be of great help.
 

Attachments

Mike Olmsted

Member
Licensed User
Hi Kluas,

Sorry for the delayed reply.

1. I am using Sql Studio. it creates Database in DBF format and not .db format. Is there any other way which i can use to create .db files?
IF yes kindly let me know

2. I have attached the sample project which is same as tableV1_24. Only thing is i am loading the contents using LoadTableFromCSV method.
Kindly let me know the mistake i am making. Is it possible to give an example to using the LoadTableFromCSV. It would be of great help.

This fixes it.....
 

Attachments

klaus

Expert
Licensed User
@duneplodder
Adding a different color for each cell would need a more deep modification of the class.
Because we need to add data to remember the background for each cell or at least for the modified cells which is currently not the case.
I'm afraid that this would slow down the loading of big tables.

Best regards.
 

klaus

Expert
Licensed User
@shashkiranr
In your code two problems:
1) You should use
Table1.LoadTableFromCSV(File.DirAssets,"mydatabase.csv",True) because your csv file has headers.
instead of
Table1.LoadTableFromCSV(File.DirAssets,"mydatabase.csv",False) in your case the haeder line is considered as the first row line !

2) As Mike Olnsted already reported you should add a line similar to this one after the previous one:
Table1.SetColumnsWidths(Array As Int(100dip, 100dip, 100dip))
Unfortunately the LoadTableFromCSV routine didn't set column widths by default.

Attached you find an amended version 1.25.
I added also a new routine :
LoadTableFromCSV2(Dir As String, Filename As String, HeadersExist As Boolean, SeparatorChar As String, AutomaticWidths As Boolean)
This routine alows to set the separator character and set an automatic column width calculation.
I kept the LoadTableFromCSV routine for backward compatibility.

To look at SQLite DB files I use a free program SQLite2009 Pro but there are also others.

Best regards.

EDIT:
Removed the zip file, the latest version is in the first post.
 
Last edited:

zeuspower

Member
Licensed User
very good..
One problem,i have is when I use the LOADSQLITE and auto-width of columns,I can't put my own header names...
it receives automatic the field headers of my DB...

how to ?
 

vecino

Well-Known Member
Licensed User
Hello, the good version is the first post (v1.20) or that of the last post (1.25)?
Thanks and regards.
 
Top