iOS Question IOS Flexgrid width

David Hawkins

Active Member
Licensed User
Longtime User
Hi I am retrieving data from an external database which I want to show in a flexgrid, I can retrieve the data OK but when I put it in a flexgrid using the following code

I call a loadlayout page which has 1 flexgrid and 1 button the flexgrid has 2 columns

column 1 is not visible
column 2 is set at 100%x

Header cells:
        FlexGrid1.ColsName = Array As String("ID", "Company Names")
        FlexGrid1.HeaderFont = xui.CreateDefaultBoldFont(16)
        FlexGrid1.ColsWidth = Array As Int(0, 100%x)
        FlexGrid1.ColsType = Array As Int(FlexGrid1.TypeInt, FlexGrid1.TypeButton)
        FlexGrid1.ColsAlignment = Array As String("CENTER", "CENTER")

then I fill the flexgrid with follwing code

Flexgrid View:
For Each colroot As Map In R
    FlexGrid1.AddRow2(Array As Object(colroot.Get("ID"), colroot.Get("CompanyName")), 80dip, True)
Next

and when viewed it only shows up on the left side of the flexgrid which is only 50% wide and not the full width as it does on the B4A version

Any ideas?
 

Star-Dust

Expert
Licensed User
Longtime User
Make sure it's docked correctly in the Layout.
When you use the ColsWidht command you give width to the columns and not to the whole grid. If the grid doesn't cover the entire width the columns will fit.

In case there is an animation in the Layout when the grid is created the parent panel may not have the final size, so you could put the ColsWidth in the Resize event. Or wait at least 400ms (the time of the animation) to resize the columns inside the grid
 
Upvote 0

David Hawkins

Active Member
Licensed User
Longtime User
Hi Star-Dust

the loadlayout file includes the following

both anchors are set

FlexGrid1.Width = 100%x
FlexGrid1.SetLeftAndRight(0, 100%x)
FlexGrid1.SetTopAndBottom(0, 80%y)

when I change the flexgrid creation to the following
Header:
        FlexGrid1.ColsName = Array As String("ID", "Company Names")
        FlexGrid1.HeaderFont = xui.CreateDefaultBoldFont(16)
        FlexGrid1.ColsWidth = Array As Int(0, 380)
        FlexGrid1.ColsType = Array As Int(FlexGrid1.TypeInt, FlexGrid1.TypeButton)
        FlexGrid1.ColsAlignment = Array As String("CENTER", "CENTER")

and set animation to 0 it works the question is it is not accepting the 100%x as the width of the screen and the 380 is purely guess work it needs to be more accurate

Regards
David
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Ciao polvere di stelle

il file loadlayout include quanto segue

entrambe le ancore sono impostate

FlexGrid1.Width = 100%x
FlexGrid1.SetLeftAndRight(0, 100%x)
FlexGrid1.SetTopAndBottom(0, 80%y)

quando cambio la creazione di flexgrid nella seguente
Header:
 FlexGrid1.ColsName = Array As String("ID", "Nomi società")
        FlexGrid1.HeaderFont = xui.CreateDefaultBoldFont(16)
        FlexGrid1.ColsWidth = Array As Int(0, 380)
        FlexGrid1.ColsType = Array As Int(FlexGrid1.TypeInt, FlexGrid1.TypeButton)
        FlexGrid1.ColsAlignment = Array As String("CENTER", "CENTER")

e imposta l'animazione su 0 funziona, la domanda è che non accetta il 100% x come larghezza dello schermo e il 380 è puramente un lavoro di supposizione che deve essere più preciso

Saluti
Davide
Use 380dip if you want to use points and not just 380.
It's probably a problem you have in the code because as you see in the examples it works correctly
 
Upvote 0
Top