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,051
  • xnGrid2xx_1.png
    xnGrid2xx_1.png
    77.2 KB · Views: 5,107
  • xnObjects267.zip
    75.7 KB · Views: 788
  • xnObjects272.zip
    87.2 KB · Views: 590
  • xnObjects273.zip
    87.5 KB · Views: 686
  • xnObjects276.zip
    87.2 KB · Views: 1,427
Last edited:

fatman

Active Member
Licensed User
Longtime User
Hi Stefano,

is it possible to colorize single cells?

Would be glad to seeing that feature.

Thx Fatman
 

stefanobusetto

Active Member
Licensed User
Longtime User
Now it's not possible.
I've already thought about the problem.
It can be solved either with a list of colors for the cells
or with an OnDrawCell event.
I've not yet added the feature because i fear a loss of
responsiveness (when the grill scrolls).
I'll do some tests and may be i'll add in the next version.
Thanks for the suggestion anyway.
:)
 

fatman

Active Member
Licensed User
Longtime User
Hi Stefano,

thank you very much for your answer.
Don´t mind if this is not possible.
Anyway I will for the next version of your lib.

Fatman
 

TFD

New Member
Licensed User
Longtime User
Hi Stefan,

I hava a problem with the RowsDelete function. When I use this, the rows get deleted, but when I want to populate the grid again, nothing happens.

If I use Rowdelete(i) and delete all the rows seperately, then everything works as expected and I can fill the grid again.
I use Version 2.52.

Dennis
 

stefanobusetto

Active Member
Licensed User
Longtime User
I've tried to reproduce the error starting form the xnGridSample
app i've posted with the xnGrid but i've not been able.
Obviously i miss something.
May you post a sample code please?
:)
 

Harris

Expert
Licensed User
Longtime User
Screenshot_2014-05-15-19-25-50.png


stefanobusetto

What a treat!

Now even easier to use with everything you have done... Effortless and looks great. Hort and Vert scroll are smooth...

Question: Don't quite fully understand the following methods, maybe you could point me to the definitions?

CursorAppend
CursorAppendRow
CursorInsert
CursorInsertRow


Thanks so much again

Harris
 

stefanobusetto

Active Member
Licensed User
Longtime User
Hi
nice to hear you again.
The methods add rows to the grid.
CursorAppendRow add one row getting the values from the cursor passed as a parameter
CursorInsertRow is the same but you can specify the row of the grid
CursorAppend and CursorInsert loop the cursor adding multiple rows to the gird
i hope i've been clear
:)
 

bl4ck4nt

Member
Licensed User
Longtime User
@stefanobusetto
I have a little problem, if I put xngrid in panel, data released can not seem everything but when placed in the activity may seem all the data. because I want put xngrid in panel in tabhost.
where should I fix or problem solving about this ...?thanx
@Guillermo Sanzeri
You can look example in first post, filename is xnGridSample200beta.zip
 

Attachments

  • xngrid-activity.png
    xngrid-activity.png
    102 KB · Views: 239
  • xngrid-panel.png
    xngrid-panel.png
    99.5 KB · Views: 241
  • test.zip
    7.4 KB · Views: 209
Last edited:

stefanobusetto

Active Member
Licensed User
Longtime User
it's not perfectly clear the problem you experience
i've this code working
B4X:
    If xngTest.IsInitialized = False Then   
      Panel1.Initialize("p1")
      Panel2.Initialize("p2")
      Panel3.Initialize("p3")
      TabHost1.Initialize("th")
      Activity.AddView(TabHost1, 0dip, 0dip, 100%x, 100%y)
   
      TabHost1.AddTab2("Color", Panel1)
      TabHost1.AddTab2("Animal", Panel2)
     

        xngTest.Initialize("xngTest")
        xngTest.FastScroll = True : xngTest.Multiselect = False
        xngTest.RowHeight = 23dip : xngTest.HeaderHeight = 23dip
        xngTest.HeaderTextSize = 14 : xngTest.RowTextSize = 14
        xngTest.HeaderTextColor = Colors.Yellow : xngTest.RowTextColor = Colors.Yellow
        xngTest.SelectedOddColor = Colors.Green : xngTest.SelectedEvenColor = Colors.Magenta
        ' set column
        Dim tCols(4) As xnGridCol
        tCols(0).Initialize2("Cek", "cek", 10%x, Gravity.CENTER)
        xngTest.ColAppend(tCols(0))
        tCols(1).Initialize2("Lokasi", "lokasi", 30%x, Gravity.CENTER)
        xngTest.ColAppend(tCols(1))
        tCols(2).Initialize2("Latitude", "latitude", 25%x, Gravity.CENTER)
        xngTest.ColAppend(tCols(2))
        tCols(3).Initialize2("Longitude", "longitude", 25%x, Gravity.CENTER)
        xngTest.ColAppend(tCols(3))
        xngTest.GridWidth = 1dip
        Panel1.AddView(xngTest, 0dip, 0dip, 100%x, 100%y)
    End If
    For i = 1 To 1000
        xngTest.RowAppend(Array As String(i, i+1, i+2, i+3))
    Next
    xngTest.GridCreate2(False)
i was not able to open your bal file because a version issue
:)
 

bl4ck4nt

Member
Licensed User
Longtime User
I found why that problem happend
B4X:
Panel1.AddView(xngTest, 0dip, 0dip, 100%x, 100%y)
must be
B4X:
Panel1.AddView(xngTest, 0dip, 0dip, Panel1.Width, Panel1.Height)
ok problem solved :)
ok thanx @stefanobusetto
 
Last edited:

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,
Anyone has try the grid with large SQL data, about 20000 rows by 7 columns.
How long does it takes to load all data?
 

stefanobusetto

Active Member
Licensed User
Longtime User
never loaded so many records

the grid first loads the data in memory
then displays the data
1) i use a java list to store the data
so the load time of a single record is always the same
no matter if it is the first loaded or the 1.000.000th
2) the display part draws only the visible rows
and the widgets are reused for performance
(very little code of my own - thanks to the google developers )
so the refresh time does not depend from the
number of records

no of much help but ...
:)
 

stefanobusetto

Active Member
Licensed User
Longtime User
the xnGridSample app running on a samgung yp-g70
CPU 1000 MHz
RAM 512MB
Android 2.3
takes 1 second to load and display 20000 rows x 4 columns
filing the grid with a loop
:)

anyway if i may suggest
i'll not load so much data in a grid
it's not very easy for a user to scroll such
a huge quantity of data to find what he's searching
:):)
 

Ankerdata

New Member
Licensed User
Longtime User
Hi

i have a Question, Is it Possible to Select A row In xnGrid then Get the values only from the Selected Row and Edit the Row that is Selected Or the xnGrid is just for Displaying Records/Report?

Thank You
 

stefanobusetto

Active Member
Licensed User
Longtime User
hi
you can select a row
get the values of the selected row
( you can also set the values )
but the grid is only for displaying
:)
 

TheMightySwe

Active Member
Licensed User
Longtime User
Hi, do you think it's possible to have the Left, Top, Width and Height values on the cell that is _Select or _Long_select or maybe a _Cell_Select event where those values can be read? Or if the Touch coordinates in some way could be accessed?
 
Top