Android Question b4xtable visible only after start entering text at Searchfield

zeuspower

Member
Licensed User
Longtime User
Hello guys...
I want to display data on the table only after the user starts to enter text at the searchfield
 

PaulMeuris

Active Member
Licensed User
What you want to do is not standard behavior of a B4XTable.
There is a "workaround" though.
Here's what i did:
In the designer i placed an EditText field on top of the place where the SearchField normally is.
1668505969372.png

And then in the code right after the SetData method i placed the following code:
B4X:
    B4XTbl1.SetData(data)
    'B4XTbl1.NumberOfFrozenColumns = 1
    If B4XTbl1.SearchField.TextField.Text = "" Then
        B4XTbl1.SearchVisible = False
        B4XTbl1.clvData.sv.Visible = False
    End If
Note that any frozen columns will still be displayed.
The SearchVisible property hides the search field.
The clvData scrollview is also hidden.
Then for the EditText field i wrote the following code:
B4X:
Private Sub EditText1_TextChanged (Old As String, New As String)
    If New = "" Then
        B4XTbl1.clvData.sv.Visible = False
    Else
        B4XTbl1.SearchField.TextField.Text = New
        B4XTbl1.clvData.sv.Visible = True
    End If
End Sub
Now when the user types something in the EditText field the search will be shown in the B4XTable.
And when the EditText field is cleared the B4XTable is empty again.
Is this what you want to do?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
I want to display data on the table only after the user starts to enter text at the searchfield
Here is a simple way without having to add an edittext to accomplish what you want . Full code:
B4X:
Sub B4XTable1_DataUpdated
    If B4XTable1.SearchField.TextField.Text = "" Then
         B4XTable1.clvData.sv.Visible = False
    Else
         B4XTable1.clvData.sv.Visible = True
    End If
End Sub
 
Upvote 0
Top