B4A Library Grid/Table and ListView Library

stefanobusetto

Active Member
Licensed User
with the current version of the grid no
i'm sorry

the 1.x version of the grid will have no upgrades or new features

i'm currently testing the 2.0 version of the grid i'm going to post soon

the new version will be mostly compatible with the previous one
and will allow to add some new features i need
1) columns with check boxes
2) columns with images
3) multi row grid lines
i'll add your request to the todo list
:)
 

aviario

Active Member
Licensed User
with the current version of the grid no
i'm sorry

the 1.x version of the grid will have no upgrades or new features

i'm currently testing the 2.0 version of the grid i'm going to post soon

the new version will be mostly compatible with the previous one
and will allow to add some new features i need
1) columns with check boxes
2) columns with images
3) multi row grid lines
i'll add your request to the todo list
:)
Hi,
We'd like have an independient Gravity for Header and another Gravity for cells of that column. For example, we want center text header, but for this column we want left align for cells(data).

Many thanks
 

aviario

Active Member
Licensed User
Scroll

Hello
If a layout put a ScrollView and I need to have the vertical scroll scroll through the screen grid scroll stops working, as I can fix it

un saludo
Paco
 

stefanobusetto

Active Member
Licensed User
Grid 1.xx

Version 1.10
- row highlight even if no select sub is present
- xnTable now supports insert and delete
- xnTable now supports insert and append from map object

Version 1.15
- column gravity
- header text size and color
- rows text size and color for odd and even rows

Version 1.16
- added SelectedOddColor
- added SelectedEvenColor

Version 1.20
- added multiselection

Version 1.21
- added ability to enable horizontal scroll
- added ability to enable vertical scroll
- minor fixes

Version 1.30
- xnTable integrated in xnGrid
- added insert row
- added delete row
- added syncing between xnTable and xnGrid (SetValue)

Version 1.40
- added MapInsertRow/MapAppendRow
- added CursorInsertRow/CursorAppendRow
- added CursorInsert/CursorAppend
- added JsonInsert/JsonAppend

Version 1.46
- added SelectedCol

Version 1.48
- added TextColor
- Inverted parameters for MapInsertRow/CursorInsertRow
- Inverted parameters for CursorInsert/JsonInsert


see example code

Version 1.49
- added rows properties ( color : SetPropColor ( Row , Color ) )
- added long_select

Version 1.50
- added GetValue2/SetValue2 ( get and set values by field name )
- added long_select event

Version 1.51
- added bulk load capabilities (experimental)

Version 1.52
- added method SelectClear
- fixed a bug in BulkCursorAppend

Version 1.53
- added ScrollUp/Down

Version 1.61
- added support for grid lines (read specific post)
- GridWidth
- GridWidthHeaderOffset
- GridWidthCheckOffset
- GridWidthTextOffset
- added method GetColumn
- minor fixes
- updated sample code

Version 1.62
- added rows properties ( color : SetPropTextColor ( Row , Color ) )

Version 1.63
- added alternate coloring for groups of rows ( property ColumnColor )
rows are colored in groups using the OddColor/EvenColor
the color changes every time changes the value of the Column
specified in the ColumnColor property ( -1 means no group coloring )

Version 1.65
- added 4 objects
- xnObjDate
- xnObjInteger
- xnObjDouble
- xnObjString

Version 1.67
- added
- xnObjBoolean
- fixed a bug

Version 1.68
- added
- ScrollBy
- ScrollTo

Version 1.69
- added
- header_click event

Version 1.71
- added horz & vert alignement for cell contents
- removed ( become useless ! )
- GridWidthHeaderOffset
- GridWidthCheckOffset
- GridWidthTextOffset

Version 1.72
- fixed SetValue bug
- speeded up data loading
- removed bulk methods ( become useless ! )

Version 1.73
- fixed bug in JsonAppend/JsonInsert
- speed optimizations

Version 2.00 beta
It is a major refactoring of version 1.xx
- New data structures
- New view creation pattern
- Renamed methods AppendCol, DeleteCol and InsertCol to ColAppend, ColDelete, ...
- Renamed methods AppendRow, DeleteRow and InsertRow to RowAppend, RowDelete, ...
Not yet available
- ScrollDown / ScrollUp ...
- SetPropColor / SetPropTextColor / ...


Version 2.01 beta
- Added ScrollTop / ScrollBottom / ScrollTo

Version 2.02 beta
- Added header alignement
- Added header icons
- Added HELP (javadoc)

Version 2.04 beta
- Check columns
- Image columns

Version 2.05 beta
- Added CheckIcon / CHeckValue properties
- Added SelectRow / SelectClear methods

Version 2.07 beta
- Added PropSetHeight
- Added FastScroll

Version 2.10
- Bug fixes

Version 2.22
- Bug fixes

Version 2.25
- Bug fixes
- Added String Conversion Routines
 
Last edited:

qsrtech

Active Member
Licensed User
Hi is this new version going to break existing projects or did you keep previous method names for compatibility? If so is there a way to rename the library to something like xnObjects2 so that both libraries can be used?

Thanks!
John
 

stefanobusetto

Active Member
Licensed User
Hi
the new library is planned to have all the features of the previous one.

But i've renamed (as you noticed) a few methods:
1) InsertRow to RowInsert
2) AppendRow to RowAppend
3) DeleteRow to RowDelete
4) InsertCol to ColInsert
5) AppendCol to ColAppend
6) DeleteCol to ColDelete
7) ScrollUp to ScrollTop
8) ScrollDown to ScrollBottom

There are no changes in the parameters kind or order except for:
a) GridCreate2 that now accepts only 1 parameter instead of 2.
public void GridCreate2 ( boolean ScrollHorizontal )
instead of
public void GridCreate2 ( boolean ScrollHorizontal , boolean ScrollVertical )
b) ScrollTo
public void ScrollTo ( int Row )
instead of
public void ScrollTo ( int x , int y )
This is the only big change. The input is the number of rows instead of the number of pixels.

I've renamed the methods to have all the methods working with rows and columns grouped toghether.

I've planned (if someone requests) to create wrappers for the new methods with the names of the old ones.
These wrappers will be marked as "discouraged" and will kept in the new lib for a while to allow a painless migration.

Should you have any request or suggestion you are welcome.
:)

I'm also looking for a beta tester.
:):)
 

aviario

Active Member
Licensed User
Hello,

we have problems in some phones, because grid doesn't work, doesn't work scroll, but in a tablet works.

Thanks
 

Attachments

aviario

Active Member
Licensed User
Do you mean version 2.x?
Version 1.x works?
Which android version? Which phones? May be i can find one.
Version 2.1 ( xnObjects201.zip )

Tablet Fujitsu - M532 (android versión: 4.0.3 ) works ok
Phone - LG-P999 ( android vesión: 4.2.2 ) works Ok
Phone - Samsung-GT-I9003 ( android Versión: 2.2.1 ) not work
Phone - Huavei-P(U9200) ( android versión 4.0.3 ) not work
Phone - Samsung Galasy S3(GT-19300) ( android versión 4.1.2 ) not work

Version 1 ( xnObjects173.zip )

Tablet Fujitsu - M532 (android versión: 4.0.3 ) works ok
Phone - LG-P999 ( android vesión: 4.2.2 ) works Ok
Phone - Samsung-GT-I9003 ( android Versión: 2.2.1 ) not work
Phone - Huavei-P(U9200) ( android versión 4.0.3 ) not work
Phone - Samsung Galasy S3(GT-19300) ( android versión 4.1.2 ) not work
 

stefanobusetto

Active Member
Licensed User
please try this
B4X:
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub

Sub Globals
Dim gg As xnGrid
End Sub

Sub gg_fill
Dim t0 As Long
Dim t1 As Long
Dim dd As Long

t0 = DateTime.Now
For r = 0 To 100
    Dim v As String
    If r Mod 3 = 0 Then
       v = ""
    Else 
       v = "o=" & r
    End If
   
   gg.RowAppend ( Array As String ( "c=" & r , "d=" & r , "g=" & r , v ) )
Next
t1 = DateTime.Now

dd = t1 - t0 
Log ( dd )
End Sub

Sub Activity_Create(FirstTime As Boolean)
Dim bt_paint As Button

Dim t As Int : t = 5dip
Dim h As Int : h = 45dip

' create buttons
bt_paint.Initialize("bt_paint")
bt_paint.Text = "create" 
Activity.AddView ( bt_paint ,  0dip , t ,  90dip , 40dip )

t = t + h

If gg.IsInitialized = False Then
   gg.Initialize("gg")
   gg.RowHeight = 48dip 
   
   gg.HeaderHeight = 30dip
   
   gg.HeaderTextSize = 13
   gg.RowTextSize = 13 
   
   gg.HeaderTextColor = Colors.Yellow
   gg.RowTextColor = Colors.Yellow

   gg.SelectedOddColor = Colors.Green
   gg.SelectedEvenColor = Colors.Magenta

   Dim cc(4) As xnGridCol

   cc(0).Initialize2 ( "Cod." , "cod" , 40dip , Gravity.TOP + Gravity.LEFT )
   gg.ColAppend ( cc(0) )

   cc(1).Initialize2 ( "Des." , "des" , 0dip , Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL)
   gg.ColAppend ( cc(1) )

   cc(2).Initialize2 ( "Grp." , "grp" , 60dip , Gravity.BOTTOM + Gravity.RIGHT )
   gg.ColAppend ( cc(2) )

   cc(3).Initialize2 ( "Other" , "other" , 60dip , Gravity.LEFT )
   gg.ColAppend ( cc(3) )

   Activity.AddView ( gg , 5dip , t , 180dip , 100%y - t - 10dip )

   gg_fill 
   bt_paint_click
End If
End Sub

Sub bt_paint_click
gg.Multiselect = False
gg.GridWidth = 1dip
gg.GridColor = Colors.Red
gg.PixelFix = False

Dim t0 As Long
Dim t1 As Long
Dim dd As Long

t0 = DateTime.Now
gg.GridCreate2 ( False ) 
t1 = DateTime.Now

dd = t1 - t0 
Log ( dd )
End Sub
 

aviario

Active Member
Licensed User
Hi,
thanks for reply.

This example are working because you are using this line:
Activity.AddView ( gg , 5dip , t , 180dip , 100%y - t - 10dip )
but if i use this one:
MyScrollView.Panel.AddView ( gg , 5dip , t , 180dip , 100%y - t - 10dip )
then it doens't work, and i need add a grid in a ScrollView, because i need use it in some cases.

Thanks
 

stefanobusetto

Active Member
Licensed User
I see no way to solve the problem of the grid inside a scrollview.
The grid uses a ListView and Google states you can't do that.
For reference you can look ath the pdf page 49.
Google I/O 2010

I'm sorry.
 

stefanobusetto

Active Member
Licensed User
Version 2.02 beta
- Added header alignement
- Added header icons
- Added HELP (javadoc)

B4X:
cc(1).Initialize2 ( "Des." , "des" , 40dip , Gravity.CENTER_VERTICAL + Gravity.CENTER_HORIZONTAL)
cc(1).HeaderGravity = Gravity.TOP + Gravity.LEFT
gg.ColAppend ( cc(1) )
B4X:
Dim bmp As Bitmap
bmp.Initialize ( File.DirAssets , "header_icon.png" )

...

cc(0).Initialize2 ( "" , "cod" , 40dip , Gravity.TOP + Gravity.LEFT )
cc(0).HeaderIcon = bmp 
cc(0).HeaderIconTop  = 3dip 
cc(0).HeaderIconLeft = 3dip 
gg.ColAppend ( cc(0) )
 
Last edited:

stefanobusetto

Active Member
Licensed User
Image columns ( how-to )

1) load the images
images must be put into the files folder of the b4a project
B4X:
Dim bmp(6) As Bitmap
bmp(0).Initialize ( File.DirAssets , "0.png" )
bmp(1).Initialize ( File.DirAssets , "1.png" )
bmp(2).Initialize ( File.DirAssets , "2.png" )
bmp(3).Initialize ( File.DirAssets , "3.png" )
bmp(4).Initialize ( File.DirAssets , "4.png" )
bmp(5).Initialize ( File.DirAssets , "5.png" )
2) define the column and the image association
B4X:
cc(0).Initialize ...
cc(0).RowIconPut("a",bmp(1))
cc(0).RowIconPut("b",bmp(2))
cc(0).RowIconPut("c",bmp(3))
cc(0).RowIconPut("d",bmp(4))
cc(0).RowIconPut("e",bmp(5))
cc(0).RowIconTop = 6dip 
cc(0).RowIconLeft = 6dip 
cc(0).SetTypeImage
if the value of the column is "a" then the column will display the "1.png" icon
if "b" the "2.png" icon ... if the value has no associated icon then no icon will be displayed
:)
 
Last edited:
Top