B4A Library Grid/Table and ListView Library

This library allows to create easely grids/tables and
from version 2.50
list views too!
Enjoy!
:)

The original post has been moved
http://www.b4x.com/android/forum/threads/grid-library.16381/page-10#post-168452"

Version 2.50 beta
- Added support for multiline rows

Version 2.51 beta
- Bug fixes

Version 2.52 beta
- Added Typeface support for rows and hedaer

Version 2.53
- Added SingleLine property for columns

sample code and usage hints can be found here
http://www.b4x.com/android/forum/threads/grid-library.16381/page-15#post-194602

Version 2.55
- Added object b4aActivityContext

Version 2.56
- Added and modified event hendlers
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-297198

Version 2.57
- Added Columns Builders
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-299406

Version 2.58
- Bug fixes

Version 2.59
- Added RowHeight for each column
- Added HeaderHeight for each column
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-304465

Version 2.60
- Added TouchX() and TouchY()
- Added FirstVisiblePosition() and LastVisiblePosition()
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-304905

Version 2.65
- Added Button Columns
https://www.b4x.com/android/forum/threads/grid-and-listview-library.16381/page-19#post-306507

Version 2.67
- Added CellProps event
- Removed PropSetColor / PropSetTextColor
https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/page-19#post-307490

Version 2.71
- Added OnSelectAllow event
- Added selection on row background
https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/page-21#post-347618

Version 2.73
- Added OnRowProps event
https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/page-21#post-349404

Version 2.76
- Fixed dubug log bug
https://www.b4x.com/android/forum/threads/grid-table-and-listview-library.16381/page-21#post-375965

If you like my grid.
You can support the development.


 

Attachments

  • xnGridSample200beta.zip
    3.6 KB · Views: 2,172
  • xnGrid2xx_1.png
    xnGrid2xx_1.png
    77.2 KB · Views: 5,279
  • xnObjects267.zip
    75.7 KB · Views: 912
  • xnObjects272.zip
    87.2 KB · Views: 697
  • xnObjects273.zip
    87.5 KB · Views: 788
  • xnObjects276.zip
    87.2 KB · Views: 1,558
Last edited:

stefanobusetto

Active Member
Licensed User
Longtime User
Yust set the changed value in the grid
gg.SetValue ( aRow , aCol , aNewValue )
or
gg.SetValue2 ( aRow , aColName , aNewValue )
where aRow and aCol are the row index and the column index
and aNewValue is the new value for the cell.
You can use the column name too (SetValue2 ).
Or you can replace all the values of a row with the
SetValues method.
You have also the gg.SetValueSafe and gg.SetValueSafe2
methods. These methods also checks the ranges of the
parameters passed.
No need to recreate or even refresh the grid.
:)
 

qsrtech

Active Member
Licensed User
Longtime User
I'm not sure if it's posted here anywhere but I just want to post a tip about scrolling rows in case someone else runs into it. I've found that you need do the "Scroll" after selecting a row, so if you want to select the row you're scrolling to you need to do it after you scroll and not before, otherwise it will not scroll to it.
 

stefanobusetto

Active Member
Licensed User
Longtime User
On Select Allow Event
Now you can prevent row selection using the "On_Select_Allow" event.

B4X:
Sub gg_on_select_allow ( aRow As Int , aValues() As String , aOnSelect As xnGridOnSelect )
Log ( "on select allow" )
If aRow = 2 Then
   aOnSelect.Allow = False
End If
End Sub

Parameters
aRow : the row number
aValues : the values of the row

aOnSelect : the selection options ( only allow true/false for now )

Note
Allow is set to true by default.
 
Last edited:

stefanobusetto

Active Member
Licensed User
Longtime User
On Row Props Event
Can be used to set the properties of each row (height for now).

B4X:
Sub gg_RowProps ( aRow As Int , aValues() As String , aProps As xnGridRowProps )
If aRow = 5 Then
   aProps.Height = 100dip
End If
End Sub

Parameters
aRow : the row number
aValues : the values of the row

aProps : the row properties
 

qsrtech

Active Member
Licensed User
Longtime User
Do you think it possible for you to add a pinch to zoom feature? Essentially I think it would just be an algorithm to increase/decrease the font/column size.
 

stefanobusetto

Active Member
Licensed User
Longtime User
good idea!
i've tryed to add freeze columns more than once
but i've not yet been able
may be it'll be the right time
:)
 

David Hawkins

Active Member
Licensed User
Longtime User
Hi Stefano
is it possible to get the dimensions of the a cell that has been selected i.e. Top left position, width and height.

Regards

David
 

David Hawkins

Active Member
Licensed User
Longtime User
Hi Stefano

I am trying to put a tick in a column with this code but it appears not to work could you check it for me please as I am probably missing something.

private Sub LoadGrid

CLGrid.Initialize("CLGrid")
CLGrid.RowHeight = 15%y
CLGrid.HeaderHeight = 7%y
CLGrid.HeaderTextSize = 16
CLGrid.HeaderTextColor = Colors.White
CLGrid.HeaderTypeface = Typeface.DEFAULT_BOLD
CLGrid.HeaderColor = Colors.Black

Dim cc(3) As xnGridCol
cc(0).Initialize2 ("Test", "TEST", 15%x, Gravity.LEFT):CLGrid.ColAppend ( cc(0))
cc(1).Initialize2 ("Test1", "TEST1", 15%x, Gravity.LEFT):CLGrid.ColAppend ( cc(1))
cc(2).Initialize2 ("Test2", "TEST2", 15%x, Gravity.LEFT):CLGrid.ColAppend ( cc(2))

cc(0).RowIconTop = 2%y
cc(0).RowIconLeft = 2%x
cc(0).setTypeCheck

cc(1).RowIconTop = 2%y
cc(1).RowIconLeft = 2%x
cc(1).setTypeCheck

Activity.AddView (CLGrid, 0%x, 0%y, 45%x, 40%y)

CLGrid.RowAppend( Array As String("","1", ""))
CLGrid.RowAppend( Array As String("1","", "1"))

CLGrid.Visible = True
CLGrid.GridWidth = 1
CLGrid.PixelFix = False

CLGrid.GridCreate2(False)
End Sub

private Sub CLGrid_CellClick ( Col As Int , Row As Int )
Dim result As Int

result = Msgbox2("Please select Yes for a Tick", "", "Yes", "", "No", Null )

If result = DialogResponse.POSITIVE Then
CLGrid.SetValue(Row ,Col , "1")
Else
CLGrid.SetValue(Row ,Col, "0")
End If

End Sub
 
Top