B4J Question B4xTable - checkbox - problem with resizing

DarkoT

Active Member
Licensed User
Hi,
have somebody idea how to solve the checkbox inside of B4Xtable when users want to resize form...

Initial view look like:

1661191352436.png


When user drag form to left, checkbox (created like panel inside of table) will not stay in center of column:

1661191442111.png


Mycode:

CheckBox inside of B4xTable:
' osvežimo prikaz podatkov
Private Sub RefreshTableGrid

    Query = $"select SifOddelekID, SifOddelekCode, SifOddelekDescription, SifOddelekCreatedAtt, SifOddelekModifiedAtt, SifOddelekIsDeleted, SifOddelekIsNonActive
              from SifOddelki
              where isnull(SifOddelekIsDeleted,0) = 0
              Order by SifOddelekID desc"$
    Dim rs As ResultSet = Main.MsSql.ExecQuery(Query)
    Dim row As List
    row.Initialize
   
    Do While rs.NextRow
        row.Add(Array(rs.GetInt("SifOddelekID"), rs.GetString("SifOddelekCode"), rs.GetString("SifOddelekDescription"), rs.GetString("SifOddelekModifiedAtt"), rs.GetInt("SifOddelekIsNonActive") ))
    Loop
    rs.Close
   
    Wait For (tableSifrant.SetData(row)) Complete (Unused As Boolean)
   
    ' mark as checkbox
    For i = 1 To colNonActive.CellsLayouts.Size - 1
   
        Dim p As B4XView = colNonActive.CellsLayouts.Get(i) '0 = header
        Dim chk As CheckBox
        chk.Initialize("chk")
        p.AddView(chk, colNonActive.ComputedWidth / 2 - 20dip, tableSifrant.RowHeight / 2 - 20dip, 40dip, 40dip)
    Next

   
    tableSifrant.Refresh
End Sub

need help... ;)
 

DarkoT

Active Member
Licensed User
@Erel - thank's... It works perfectly... Just one aditional question... How to mark records as checked - when is Value = True... I tried with code:

Example:
For i = 0 To tableSifrant.VisibleRowIds.Size - 1
        Dim RowId As Long = tableSifrant.VisibleRowIds.Get(i)
        
        If RowId > 0 Then
            Dim p As B4XView = colNonActive.CellsLayouts.Get(i)
            Dim Oznacichk As CheckBox = p.GetView(1) 'first view is the label
            Oznacichk.Visible = RowId > 0
            Oznacichk.Tag = RowId
            Dim item As Map = tableSifrant.GetRow(RowId)
            If item.Get("NeAktiven") = "1" Then Oznacichk.Checked = True Else Oznacichk.Checked = False
it fails in error in line 5 --> p.getview(1)

Thank you..
 
Upvote 0

DarkoT

Active Member
Licensed User
p.GetView(1) returns the panel that holds the layout.
B4X:
Dim pnl As B4XView = p.GetView(1)
Dim chk As B4XView = pnl.GetView(0)
Thank you.. Works perfect... Thank's for help...
 
Upvote 0
Top