B4A Library [Class] Flexible Table

Bryan

Member
Licensed User
Longtime User
No, I don't think so. Aa far as I know all routines remain the same to garanty upward compatibility.

I don't understand what you mean with possibly that will fill the cell if the cell is changed in width ?
Probably more like if the column's size is changed.

Also I forgot to ask if columns can be autosized for their text contents.

Thank you
 
Last edited:

klaus

Expert
Licensed User
Longtime User
There is no column width changed event.
Column colors can be set since version 1.36.
Also I forgot to ask if columns can be autosized for their text contents.
Yes, LoadTableFromCSV2 has as the last parameter AutomaticWidths, set it to true.
 

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.

OK, thanks

I changed to the new version but having a problem getting the SelectedRow when a user would click on a row. Older version had
in Globals
Private SelectedRow As Int (I changed it to public)
In my main activity I would have a click event as such
Table2d.RemoveRow(Table2d.SelectedRow)
This isn't working now.


New version only returns a list of selected rows.
 
Last edited:

klaus

Expert
Licensed User
Longtime User
You should add in the calling module this event routine:
B4X:
Sub Table1_CellClick (Col As Int, Row As Int)
'    Activity.Title = Table1.GetValue(Col, Row)
  
    SelectedRow = Row
  
End Sub
This event is raised when the user clicks on a cell.
You get the col and row indexes as parameters.

You could also add these event routines:
B4X:
Sub Table1_CellLongClick (Col As Int, Row As Int)

End Sub

Sub Table1_HeaderClick (Col As Int)

End Sub
 

Bryan

Member
Licensed User
Longtime User

Thanks much greatly appreciated.

Bryan
 

Espinosa4

Active Member
Licensed User
Longtime User
Hello,

I have an old problem after "install" the versión 1.36. I can't select the last row or I can but with many problems. For example I have to do click in all columns until the row is selected.

By the way... it seems that the text size is different after this version. I needed to resize all columns.

Thanks in advance
Espinosa
 

klaus

Expert
Licensed User
Longtime User
I have an old problem after "install" the versión 1.36. I can't select the last row or I can but with many problems. For example I have to do click in all columns until the row is selected.
Can you post a small project showing the problem.
In the demo program it works.
By the way... it seems that the text size is different after this version. I needed to resize all columns.
The text size has been the same since the beginning.
TextSize is a property of the table, so you can set it with Table1.TextSize = 16
RowHeight is a property too, Table1.RowHeight = 50dip
 

klaus

Expert
Licensed User
Longtime User
Sorry, but I can't test your program.
I get an error in line 528 in ActSelectionarPrueba 'Cannot assign Void value.
The TextSize prolem is not due to the Table class it is somewhere in your data becaus you change in your code.
In the Table class the default value is 14, and this has never changed.
For the TextSize you use this varaible Dim TamanyoTexto As Int or Dim TamanyoLetra As Int.
Why do you use an Int, TextSize is supposed beeing a Float variable.

For the last line I don't know what happens, as I can't test the program.
 

Espinosa4

Active Member
Licensed User
Longtime User
About the text size I use a small letter from the first time. I wanted my partners only use integer without decimals.. Why? For eliminate problems. Remember I am a dummy programmer. Sorry.

I don't know why but the same project but different table version the text size change and also the column. When I use the version 1.29 a size and when I use the 1.36 the size change again.

Sorry but I can't explain better but there's something different.

Cheers
 
Last edited:

Espinosa4

Active Member
Licensed User
Longtime User
Did you replace for the new one? How l4pro.Sql exists you need replace in the external root. In my case is Android /data/www.l4pro.tranvia /files and overwrite the file.

Sorry Klaus. Don't worry. And thanks for your help.

Cheers
 

klaus

Expert
Licensed User
Longtime User
The error I got came from an older version of the calendar2 library.

The problem is not in the Table class it's in your code in the RowHeight calculation.
You set for example the TextSize to :
TblServiciosOrdinarios.TextSize = TamanyoTexto
then you set the RowHeight to :
TblServiciosOrdinarios.RowHeight = TamanyoTexto * 4
TextSize is device scale independant but RowHeight is !
So, if you set TextSize = 12 your RowHeight is 48 pixels
This is OK on a device with a scale of 1.
If you have a device with a scale of 2, the physical RowHeight, with 48pixels, will be half of the height on a device with a scale of 1.
With the example above the RowHeight on a device with scale 2 should be 96 pixels !
I changed the RowHeight calculation to:
TblServiciosOrdinarios.RowHeight = TamanyoTexto * 2.8dip

I moved the RowHeight lines before the Initialize lines, this solves the last row selection problem.

Can you send me your e-mail adress in a private message so I can send you the modified project.
Or you can modify your code like this:
B4X:
    TblServiciosOrdinarios.Initialize(Me, "TblServiciosOrdinarios", 8,0,False)
    TblServiciosOrdinarios.CellAlignment = Gravity.LEFT
    TblServiciosOrdinarios.RowHeight = TamanyoTexto * 2.8dip
    TblServiciosOrdinarios.TextColor = Colors.blue
    If Activity.Width < Activity.Height Then
        TblServiciosOrdinarios.AddToActivity(Activity, 0,120dip, 100%x, 75%y)
    Else
        TblServiciosOrdinarios.AddToActivity(Activity, 0, 55dip, 100%x, 82%y)
    End If
    TblServiciosOrdinarios.TextSize = TamanyoTexto
    'TblServiciosOrdinarios.UseColumnColors = True '@@@@@@@
    TblServiciosOrdinarios.HeaderColor = Colors.DarkGray
 
Last edited:

Espinosa4

Active Member
Licensed User
Longtime User
Hi Klaus,

Sorry for the dalay
The code works superb! Many many thanks!!! and also folowing your advices I changed textsize to float

Best regards,
Espinosa
 

tznikos

Member
Licensed User
Longtime User
Hi,

I have a cell with a large text, how i can show this text in multiple lines on the cell.
 

Attachments

  • 2014-09-06-10-49-05.png
    185.3 KB · Views: 215

tznikos

Member
Licensed User
Longtime User
Is ok now

I have added the table1.singlieLine = False but not after the Table1.initialize

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.

Anyway
Than you for the quick support.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…