B4J Question [Solved] Confusion with the header of a B4XTable

BlueVision

Well-Known Member
Licensed User
Longtime User
I'm slowly going mad. With a tiny B4XTable I have a problem with controls in the header. Originally the search function was hidden. Can be done in the designer. No problem.
Then I realised that when scrolling through the tables, the text of the FROMTO label ‘grows’ into the controls for scrolling through the table, so there is an ugly overlap. Good. So the table controls have to be rearranged.

Step 1:
So just move the table controls completely to the right, preferably to the right edge of the table, looks best. Problem: Despite the search function being hidden, the controls seem to disappear under a label of the search function.

Step 2:
Move the search function to the left behind the FROMTO label. You can see what happens in the picture.
For test purposes, the search function has been reduced in width and shown again. It is located above the FROMTO label. Hide it and it disappears. No problem. But take a look at the controls. A mask on the right-hand side still somehow hides the table controls. The further I move the controls to the right, the more they disappear. How can I move the controls to the right?

Here is the code for moving the controls. What am I doing wrong or what am I overlooking?

B4X:
    XTOptions.SearchField.mBase.Width = 5dip
    XTOptions.SearchField.mBase.Left = XTOptions.lblFromTo.Left + XTOptions.lblFromTo.Width -150dip
    XTOptions.lblFirst.Left = XTOptions.SearchField.mBase.Left + XTOptions.SearchField.mBase.Width
    XTOptions.lblBack.Left = XTOptions.lblFirst.Left + XTOptions.lblFirst.Width
    XTOptions.lblNumber.Left = XTOptions.lblBack.Left + XTOptions.lblBack.Width
    XTOptions.lblNext.Left = XTOptions.lblNumber.Left + XTOptions.lblNumber.Width
    XTOptions.lblLast.Left = XTOptions.lblNext.Left + XTOptions.lblNext.Width

Test.jpg
 

BlueVision

Well-Known Member
Licensed User
Longtime User
No Alex, no autoscale. To illustrate the problem a little more, I have moved the table controls to the right again by 50dip (line 3), the search field remained unchanged (but is now hidden).
The area outlined in red shows the problem. It looks to me as if a label in the header simply hides the shifted controls.
Image and modified code are attached. I just can't work out what this is supposed to be.
The code for this shift can perhaps be simplified. It's not particularly elegant, but it works.
B4X:
XTOptions.SearchField.mBase.Width = 5dip
XTOptions.SearchField.mBase.Left = XTOptions.lblFromTo.Left + XTOptions.lblFromTo.Width -150dip
XTOptions.lblFirst.Left = XTOptions.SearchField.mBase.Left + XTOptions.SearchField.mBase.Width +50dip
XTOptions.lblBack.Left = XTOptions.lblFirst.Left + XTOptions.lblFirst.Width
XTOptions.lblNumber.Left = XTOptions.lblBack.Left + XTOptions.lblBack.Width
XTOptions.lblNext.Left = XTOptions.lblNumber.Left + XTOptions.lblNumber.Width
XTOptions.lblLast.Left = XTOptions.lblNext.Left + XTOptions.lblNext.Width
Test2.jpg
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Try update B4XTable.bas
B4X:
Private pnlPages As B4XView
B4X:
Private Sub UpdateSearchFieldVisibility
#if B4J
    Sleep(100) 'workaround for a JavaFX drawing bug
#end if
    SearchField.mBase.Visible = SearchVisible And CountAll > 0
    If SearchField.mBase.Visible Then
        pnlPages.Left = pnlHeader.Width - pnlPages.Width - SearchField.mBase.Width - 5dip
    Else
        pnlPages.Left = pnlHeader.Width - pnlPages.Width
    End If
End Sub
 
Last edited:
Upvote 0

PaulMeuris

Well-Known Member
Licensed User
This should work...
B4X:
    ' in B4XPage_Created
    B4XTable1.SearchVisible = False
Private Sub B4XPage_Appear
    B4XTable1.lblFirst.Parent.Left = B4XTable1.mBase.Width - 200
End Sub
Private Sub B4XPage_Resize (Width As Int, Height As Int)
    Sleep(300)
    B4XTable1.lblFirst.Parent.Left = B4XTable1.mBase.Width - 200
    B4XTable1.RefreshNow
End Sub
1740133462759.png

The pane that contains the labels moves to the right of the form...
 
Upvote 1

aeric

Expert
Licensed User
Longtime User
Try update B4XTable.bas
B4X:
Private pnlPages As B4XView
B4X:
Private Sub UpdateSearchFieldVisibility
#if B4J
    Sleep(100) 'workaround for a JavaFX drawing bug
#end if
    SearchField.mBase.Visible = SearchVisible And CountAll > 0
    If SearchField.mBase.Visible Then
        pnlPages.Left = pnlHeader.Width - pnlPages.Width - SearchField.mBase.Width - 5dip
    Else
        pnlPages.Left = pnlHeader.Width - pnlPages.Width
    End If
End Sub

Better add in Designer Script.

B4X:
'All variants script
If pnlHeader.Width < 450dip Then
    lblFromTo.Visible = False
    pnlPages.Left = 2dip
    SearchField.Left = pnlPages.Right + 2dip
Else
    lblFromTo.Visible = True
    If SearchField.Visible Then
        pnlPages.Left = pnlHeader.Width - pnlPages.Width - SearchField.Width - 5dip
    Else
        pnlPages.Left = pnlHeader.Width - pnlPages.Width
    End If
End If

1740133758880.png
 
Upvote 0

BlueVision

Well-Known Member
Licensed User
Longtime User
You all made my day! Thank you so much for that to all responders! All B4XTables in the programme are configured in a loop before being called. So it was easy to implement your suggestions. The result: exactly as wanted, perfect.
The search view was hidden in the designer and the panel with the control elements was moved to the appropriate position (I had no idea that they were on a panel). This reduces all the crazy code in the loop for configuring the table to just one line (not even a refresh is necessary). Case solved.
B4X:
XTOptions.lblFirst.Parent.Left = XTOptions.mBase.Width - 190dip
Test3.jpg
 
Last edited:
Upvote 0
Top