Android Question B4XTable - Refresh Loop

epiCode

Active Member
Licensed User
I am using this snippet to resize column width based on text for a B4XTable

It calls a refresh function in the end of "dataupdated" event

b4xtable > refresh > refresh2 > updatedata > ImplUpdateDataFromQuery > DataUpdated > refresh (LOOP)

I'm sure I've messed something but this is the stack from debugger and verified manually in code.

How do I stop this loop without losing column resize functionality which is currently not part of B4XTable?
 
Solution
ShouldRefresh will be False in the second call.
You can also catch this event with:
B4X:
If ShouldRefresh Then
        B4XTable1.Refresh
        Wait For B4XTable1_DataUpdated
    End If

epiCode

Active Member
Licensed User
ShouldRefresh will be False in the second call.
You can also catch this event with:
B4X:
If ShouldRefresh Then
        B4XTable1.Refresh
        Wait For B4XTable1_DataUpdated
    End If
Wait for works 💯
 
Upvote 0

epiCode

Active Member
Licensed User
Wait for works 💯
Spoke too soon !
It worked on emulator but not on device - which is kinda strange but now does not work on either (cached maybe)
so I had to resort to flag method. Sharing just in case it might come handy for someone else.

B4X:
In globals:
Dim updatepending as boolean

----------------------

Private Sub B4XTable1_DataUpdated
    If updatepending Then Return
    
    .....
    
    If ShouldRefresh Then
        updatepending=True
        B4XTable1.Refresh
        updatepending=False
    End If
End Sub
 
Upvote 0
Top