B4A Library Grid/Table and ListView Library

magi6162

Well-Known Member
Licensed User
1.when I edit table data in the database , how do I update the data in the grid using grd.cursorappend ( c ) ?
2.the grid is ok, but the column "Mia" don't see the bitmap.(see code)

B4X:
    grd.Initialize("grd")
    c = Main.PTalk.ExecQuery("SELECT Nome,Giorno,OrarioT,Tel,Resp,TelResp,Via,Citta,Lingua,Lat,Lon,Alt,Mia,IDC FROM Congregazioni ORDER BY Nome")

    bmpCheckTrue.Initialize ( File.DirAssets,"ic_action_spunta.png" )

    sc = grd.ColCreateAndAppend2("Nome",        "Nome",100dip,Gravity.LEFT + Gravity.CENTER_VERTICAL)
    sc = grd.ColCreateAndAppend2("Giorno",        "Giorno",75dip,Gravity.CENTER_VERTICAL + Gravity.LEFT)
    
    sc = grd.ColCreateAndAppend2("Mia",    "Mia",35dip,Gravity.CENTER_HORIZONTAL + Gravity.CENTER_VERTICAL)
    sc.RowIconLeft = TalkCode.cRowIconLeft
    sc.RowIconTop  = TalkCode.cRowIconTop
    sc.SetTypeImage
    sc.RowIconPut("1",bmpCheckTrue)
    sc = grd.ColCreateAndAppend2("IDC",        "IDC",0dip,Gravity.CENTER_VERTICAL + Gravity.LEFT)

    grd.CursorAppend(c)
   
    c.Close
   
    grd.HeaderTextSize = TalkCode.cHeaderTextSize
    grd.HeaderHeight = TalkCode.cHeaderHeight
    grd.RowTextSize = TalkCode.cRowTextSize
    grd.RowTextColor = Colors.RGB(TalkCode.cGridColor(0),TalkCode.cGridColor(1),TalkCode.cGridColor(2))
    grd.RowHeight = TalkCode.cRowHeight
    grd.GridColor = Colors.RGB(TalkCode.cGridColor(0),TalkCode.cGridColor(1),TalkCode.cGridColor(2))
    grd.GridWidth = TalkCode.cGridWidth
    grd.HeaderColor = Colors.RGB(TalkCode.cHeaderColor(0),TalkCode.cHeaderColor(1),TalkCode.cHeaderColor(2))
    grd.HeaderTextColor = Colors.RGB(TalkCode.cHeaderTextColor(0),TalkCode.cHeaderTextColor(1),TalkCode.cHeaderTextColor(2))
    grd.RowEvenColor = Colors.RGB(TalkCode.grdRowEvenColor(0),TalkCode.grdRowEvenColor(1),TalkCode.grdRowEvenColor(2))          
    grd.RowOddColor = Colors.RGB(TalkCode.grdRowOddColor(0),TalkCode.grdRowOddColor(1),TalkCode.grdRowOddColor(2))          
    grd.SelectedEvenColor = Colors.RGB(TalkCode.grdSelectedEvenColor(0),TalkCode.grdSelectedEvenColor(1),TalkCode.grdSelectedEvenColor(2))          
    grd.SelectedOddColor = Colors.RGB(TalkCode.grdSelectedEvenColor(0),TalkCode.grdSelectedEvenColor(1),TalkCode.grdSelectedEvenColor(2))          
   
    pnlGrid.AddView ( grd , 0 , 0 , pnlGrid.Width, pnlGrid.Height)
    grd.GridCreate
 

magi6162

Well-Known Member
Licensed User
May you post a small b4a example project?
:)
I resolved for 2 (error path bitmap)
but when I edit table data in the database, how do I update the data in the grid using grd.cursorappend ( c )
(in italiano: quando modifico dei valori dei campi del database , come posso far aggiornare la griglia relativa a quei dati?
(senza dover ricrearla ex-novo, se possibile)
 

stefanobusetto

Active Member
Licensed 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
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
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
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
 

magi6162

Well-Known Member
Licensed User
how can I change color to the entire row?
I think use cellprops event, but i don't know how do it.

B4X:
Sub grdI_CellProps ( aCol As Int , aRow As Int , aValue As String , aProps As xnGridCellProps )
  
    If aCol = 13 Then   'aCol = 13  width = 0  invisible
        Dim diff As Double
        diff = DateTime.Now - mv.Get(aValue)
        If diff <= 3 Then
            ' color entire row   <<<<--------------------------- here
                          .....

.........
End Sub
Help me please
thanks
 
Last edited:

qsrtech

Active Member
Licensed 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.
 

magi6162

Well-Known Member
Licensed User
i use 2.73 all ok, but in Log (when use grd.RowAppend( )) result this:
Min=5
Max=5
Sum=5
Count=1
Avg=5.0
Min=0
Max=5
Sum=5
Count=2
Avg=2.0
Min=0
Max=5
Sum=5
Count=3
Avg=1.0
Min=0
Max=5
Sum=5
Count=4
Avg=1.0
Min=0
Max=5
Sum=5
Count=5
Avg=1.0
Min=0
Max=5
Sum=5
Count=6
Avg=0.0
Min=0
Max=5
Sum=5
Count=7
Avg=0.0
Min=0
Max=5
Sum=5
Count=8
Avg=0.0
Min=0
Max=5
Sum=5
Count=9
Avg=0.0
Min=0
Max=5
Sum=5
Count=10
Avg=0.0
Min=0
Max=5
Sum=5
Count=11
Avg=0.0
Min=0
Max=5
Sum=5
Count=12
Avg=0.0
Min=0
Max=5
Sum=5
Count=13
Avg=0.0
Min=0
Max=5
Sum=5
Count=14
Avg=0.0
Min=0
Max=5
Sum=5
Count=15
Avg=0.0
Min=0
Max=5
Sum=5
Count=16
Avg=0.0
Min=0
Max=5
Sum=5
Count=17
Avg=0.0
Min=0
Max=5
Sum=5
Count=18
Avg=0.0
Min=0
Max=5
Sum=5
Count=19
Avg=0.0
Min=0
Max=5
Sum=5
Count=20
Avg=0.0
Min=0
Max=5
Sum=5
Count=21
Avg=0.0
Min=0
Max=5
Sum=5
Count=22
Avg=0.0
Min=0
Max=5
Sum=6
Count=23
Avg=0.0
Min=0
Max=5
Sum=6
Count=24
Avg=0.0
Min=0
Max=5
Sum=6
Count=25
Avg=0.0
Min=0
Max=5
Sum=6
Count=26
Avg=0.0
Min=0
Max=5
Sum=6
Count=27
Avg=0.0
Min=0
Max=5
Sum=6
Count=28
Avg=0.0
Min=0
Max=5
Sum=6
Count=29
Avg=0.0
Min=0
Max=5
Sum=7
Count=30
Avg=0.0
Min=0
Max=5
Sum=7
Count=31
Avg=0.0
Min=0
Max=5
Sum=7
Count=32
Avg=0.0
Min=0
Max=5
Sum=7
Count=33
Avg=0.0
Min=0
Max=5
Sum=7
Count=34
Avg=0.0
Min=0
Max=5
Sum=7
Count=35
Avg=0.0
Min=0
Max=5
Sum=7
Count=36
Avg=0.0
Min=0
Max=5
Sum=7
Count=37
Avg=0.0
Min=0
Max=5
Sum=7
Count=38
Avg=0.0
Min=0
Max=5
Sum=7
Count=39
Avg=0.0
Min=0
Max=5
Sum=7
Count=40
Avg=0.0
Min=0
Max=5
Sum=7
Count=41
Avg=0.0
Min=0
Max=5
Sum=7
Count=42
Avg=0.0
Min=0
Max=5
Sum=7
Count=43
Avg=0.0
Min=0
Max=5
Sum=7
Count=44
Avg=0.0
Min=0
Max=5
Sum=7
Count=45
Avg=0.0
Min=0
Max=5
Sum=8
Count=46
Avg=0.0
Min=0
Max=5
Sum=8
Count=47
Avg=0.0
Min=0
Max=5
Sum=9
Count=48
Avg=0.0
Min=0
Max=5
Sum=9
Count=49
Avg=0.0
Min=0
Max=5
Sum=10
Count=50
Avg=0.0
Min=0
Max=5
Sum=10
Count=51
Avg=0.0
Min=0
Max=5
Sum=10
Count=52
Avg=0.0
Min=0
Max=5
Sum=10
Count=53
Avg=0.0
Min=0
Max=5
Sum=10
Count=54
Avg=0.0
Min=0
Max=5
Sum=10
Count=55
Avg=0.0
Min=0
Max=5
Sum=11
Count=56
Avg=0.0
Min=0
Max=5
Sum=11
Count=57
Avg=0.0
Min=0
Max=5
Sum=11
Count=58
Avg=0.0
Min=0
Max=5
Sum=12
Count=59
Avg=0.0
Min=0
Max=5
Sum=12
Count=60
Avg=0.0
Min=0
Max=5
Sum=12
Count=61
Avg=0.0
Min=0
Max=5
Sum=12
Count=62
Avg=0.0
Min=0
Max=5
Sum=12
Count=63
Avg=0.0
Min=0
Max=5
Sum=13
Count=64
Avg=0.0
Min=0
Max=5
Sum=13
Count=65
Avg=0.0
Min=0
Max=5
Sum=13
Count=66
Avg=0.0
Min=0
Max=5
Sum=13
Count=67
Avg=0.0
Min=0
Max=5
Sum=13
Count=68
Avg=0.0
Min=0
Max=5
Sum=13
Count=69
Avg=0.0
Min=0
Max=5
Sum=13
Count=70
Avg=0.0
Min=0
Max=5
Sum=13
Count=71
Avg=0.0
Min=0
Max=5
Sum=13
Count=72
Avg=0.0
Min=0
Max=5
Sum=13
Count=73
Avg=0.0
Min=0
Max=5
Sum=13
Count=74
Avg=0.0
Min=0
Max=5
Sum=13
Count=75
Avg=0.0
Min=0
Max=5
Sum=13
Count=76
Avg=0.0
Min=0
Max=5
Sum=13
Count=77
Avg=0.0
Min=0
Max=5
Sum=13
Count=78
Avg=0.0
Min=0
Max=5
Sum=13
Count=79
Avg=0.0
Min=0
Max=5
Sum=14
Count=80
Avg=0.0
Min=0
Max=5
Sum=18
Count=81
Avg=0.0
Min=0
Max=5
Sum=21
Count=82
Avg=0.0
Min=0
Max=5
Sum=23
Count=83
Avg=0.0
Min=0
Max=5
Sum=26
Count=84
Avg=0.0
Min=0
Max=5
Sum=29
Count=85
Avg=0.0
Min=0
Max=5
Sum=32
Count=86
Avg=0.0
Min=0
Max=6
Sum=38
Count=87
Avg=0.0
Min=0
Max=6
Sum=42
Count=88
Avg=0.0
Min=0
Max=6
Sum=47
Count=89
Avg=0.0
Min=0
Max=6
Sum=51
Count=90
Avg=0.0
Min=0
Max=6
Sum=54
Count=91
Avg=0.0
Min=0
Max=6
Sum=57
Count=92
Avg=0.0
Min=0
Max=6
Sum=59
Count=93
Avg=0.0
Min=0
Max=6
Sum=62
Count=94
Avg=0.0
Min=0
Max=6
Sum=65
Count=95
Avg=0.0
Min=0
Max=6
Sum=68
Count=96
Avg=0.0
Min=0
Max=6
Sum=71
Count=97
Avg=0.0
Min=0
Max=6
Sum=74
Count=98
Avg=0.0
Min=0
Max=6
Sum=76
Count=99
Avg=0.0
Min=0
Max=6
Sum=80
Count=100
Avg=0.0
Min=0
Max=6
Sum=83
Count=101
Avg=0.0
Min=0
Max=6
Sum=86
Count=102
Avg=0.0
Min=0
Max=6
Sum=89
Count=103
Avg=0.0
Min=0
Max=6
Sum=92
Count=104
Avg=0.0
Min=0
Max=6
Sum=95
Count=105
Avg=0.0
Min=0
Max=6
Sum=97
Count=106
Avg=0.0
Min=0
Max=6
Sum=100
Count=107
Avg=0.0
Min=0
Max=6
Sum=103
Count=108
Avg=0.0
Min=0
Max=6
Sum=106
Count=109
Avg=0.0
Min=0
Max=6
Sum=109
Count=110
Avg=0.0
Min=0
Max=6
Sum=112
Count=111
Avg=1.0
Min=0
Max=6
Sum=114
Count=112
Avg=1.0
Min=0
Max=6
Sum=117
Count=113
Avg=1.0
Min=0
Max=6
Sum=120
Count=114
Avg=1.0
Min=0
Max=6
Sum=122
Count=115
Avg=1.0
Min=0
Max=6
Sum=125
Count=116
Avg=1.0
Min=0
Max=6
Sum=128
Count=117
Avg=1.0
Min=0
Max=6
Sum=131
Count=118
Avg=1.0
** Activity (main) Pause, UserClosed = true **
you've forgotten a log in code ?
 
Top