Android Question BXTable retrieves just one row from a list

Daniel44

Active Member
Licensed User
Hi everyone
I'm working with OkHttpUtils2, JSON PHP7 Xampp and BXTable. Inside a Jobdone in a specific "case" I'm trying to retrieve records from a sql setence but this task retrieves just one record having 3 records in my Table.. just retrieve the LAST INSERTED. I know is a bad practice set the table inside the jobdone and call its List but I'll fix that. The jobDone it's working fine.. I think its my method to call the BXTable loading data.. I don't know what is wrong. I've been testing adding a for next and creating another list.. I've also been creating another ForEach but nothing works fine the method just retrieves THE LAST RECORD INSERT and it showed on my phone like that

Here's part of my jobdone

B4X:
Case GRIDFIADOS
                Dim ListaFiados As List
                ListaFiados.Initialize
                
                ListaFiados = parser.NextArray  
                For i = 0 To ListaFiados.Size - 1
                    
                    Dim MapadeListaFiado As Map
                    
                    
                    MapadeListaFiado = ListaFiados.Get(i)
                  Log(MapadeListaFiado)
                    
                Next
                
                B4XTable1.AllowSmallRowHeightModifications = False
                B4XTable1.SearchField.TextField.Visible = False
                
                B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_NUMBERS)
                B4XTable1.AddColumn("FECHA", B4XTable1.COLUMN_TYPE_TEXT)
                NumberColumn = B4XTable1.AddColumn("MONTO", B4XTable1.COLUMN_TYPE_NUMBERS)
                CreateCustomFormat(NumberColumn)
                B4XTable1.AddColumn("DETALLES", B4XTable1.COLUMN_TYPE_TEXT)
'                 
                              
                 For Each colroot As Map In ListaFiados
                    
                    Dim id As String = colroot.Get("idfiado")
                    Dim fecha As String = colroot.Get("fechafiado")
                    Dim Monto As String = colroot.Get("montofiado")
                    Dim Det As String = colroot.Get("detallefiado")
                    
                    
                    Dim row(4) As Object
                    row(0) = id
                    row(1) = fecha
                    row(2) = Monto
                    row(3) = Det
                    Dim anotherlist As List
                    anotherlist.Initialize
                    anotherlist.Add(row)
                    
                    Next
                    B4XTable1.SetData(anotherlist)
                          
        End Select
    Else
        Log(Job.ErrorMessage)
        ToastMessageShow("Error: " & Job.ErrorMessage, True)
    End If
    Job.Release

You can see the Log(MapadeListaFiado) and it's retrieving 3 records but in my phone inside BXTable JUST one IS and it is the last inserted (idfiado3)

here's my log
B4X:
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Activity (main) Pause, UserClosed = true **
** Activity (est) Create, isFirst = true **
** Activity (est) Resume **
(MyMap) {idfiado=1, fechafiado=2019-11-23 18:42:13, montofiado=450, detallefiado=variosss}
(MyMap) {idfiado=2, fechafiado=2019-11-25 16:07:25, montofiado=690, detallefiado=otra vez topo
}
(MyMap) {idfiado=3, fechafiado=2019-11-25 20:53:42, montofiado=300, detallefiado=sjsjzjz}

Thank you in advance for helping me.
 

Daniel44

Active Member
Licensed User
Here's a screenshot

ONERECORD.png
 
Upvote 0

Daniel44

Active Member
Licensed User
B4X:
For Each colroot As Map In ListaFiados
                   ...
                    Dim anotherlist As List '<---- move out of the For loop
                    anotherlist.Initialize '<---- move out of the for For loop.
                    anotherlist.Add(row)
                
 Next
 B4XTable1.SetData(anotherlist)
Thank you Erel I will test it
 
Last edited:
Upvote 0

Daniel44

Active Member
Licensed User
B4X:
For Each colroot As Map In ListaFiados
                   ...
                    Dim anotherlist As List '<---- move out of the For loop
                    anotherlist.Initialize '<---- move out of the for For loop.
                    anotherlist.Add(row)
                 
 Next
 B4XTable1.SetData(anotherlist)
Excelent Erel! It works! Thank you so much!
 
Upvote 0
Top