Hello, i have create a customlist view thata load data from mysql conneccted directly with jdbc.
I see that it is a bit slow to load results and maybe the problem are the B4XComboBox inside.
I use this sub for load the B4XComboBox
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
this is where i load che combox with lazy loading
	
	
	
	
	
	
	
		
			
			
			
			
			
		
	
	
	
		
	
	
		
	
		
		
	
	
		 
	
There are other ways?
is it possible load faster or better?
			
			I see that it is a bit slow to load results and maybe the problem are the B4XComboBox inside.
I use this sub for load the B4XComboBox
			
				B4X:
			
		
		
		Sub LoadFilterComboBox(ComboBox As B4XComboBox, Tablename As String, Columnname As String,filter As Boolean, filterField As String, filterResult As String)
    Dim lstCombo As List
    lstCombo.Initialize
   
    Dim TablenameID As String = Tablename.Replace("tbl_", "") & "ID"
    Log(TablenameID)
    ' Esegui una query per recuperare i dati dinamicamente da MySQL
    If filter = True Then
        Dim Query As String = "SELECT " & TablenameID.Trim & "," & Columnname.Trim & " FROM " & Tablename.Trim & " WHERE "  & filterField.Trim & " = '" & filterResult.Trim & "' ORDER BY " & Columnname.Trim
       
    Else
       
        Dim Query As String = "SELECT " & TablenameID.Trim & "," & Columnname.trim & " FROM " & Tablename.trim & " ORDER BY " & Columnname.trim
        Log(Query)
    End If
    Log(Query)
    Dim ResultSet As SD_ResultSet = Main.MYSQL.ExecQuery(Query)
    ' Verifica se la query ha successo
    If ResultSet <> Null Then
        ' Svuota gli elementi esistenti della ComboBox
        Log(ResultSet)
        ' Aggiungi i risultati alla ComboBox dinamica
        ComboBox.cmbBox.Items.Clear
        Do While ResultSet.NextRow
            lstCombo.Add(ResultSet.GetString(Columnname)) ' Aggiunge il valore alla ComboBox dinamica
        Loop
   
        ResultSet.Close
   
        ComboBox.SetItems(lstCombo)
    Else
        Log("Query fallita.")
   
    End If
End Subthis is where i load che combox with lazy loading
			
				B4X:
			
		
		
		Private Sub clvUsrLst_VisibleRangeChanged(FirstIndex As Int, LastIndex As Int)
    Dim ExtraSize As Int = 25 ' Estensione del range visibile
    ' Inizializza la lista Layouts solo una volta
    If Layouts.IsInitialized = False Then Layouts.Initialize
    helper.LoadExtendedComboBox(cmbCompany, "tbl_company", "CompanyName",lstcompany)
    helper.LoadExtendedComboBox(cmbWorkerty, "tbl_worker_types", "WorkerTypeName",lstWorkerty)
    helper.LoadExtendedComboBox(cmbLocation, "tbl_location", "LocationName",lstLocation)
    helper.LoadExtendedComboBox(cmbDepartement, "tbl_department", "DepartmentName", lstDepartement)
   
    ' Scorri gli elementi entro il range visibile + margine
    For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, clvUsrLst.Size - 1)
        'Dim Pnl As B4XView = clvUsrLst.GetPanel(i) ' Pannello corrente
        Panel1 = clvUsrLst.GetPanel(i) ' Pannello corrente
        Dim tdettagli As usrDetails = clvUsrLst.GetValue(i) ' Dati dell'elemento corrente
        If i >= FirstIndex - ExtraSize And i <= LastIndex + ExtraSize Then ' Elemento visibile
            If Panel1.NumberOfViews = 0 Then ' Carica solo se non già visibile
                Dim content As B4XView
                If Layouts.Size > 0 Then
                    ' Riutilizza un layout esistente
                    content = Layouts.Get(0)
                    Layouts.RemoveAt(0)
                Else
                    ' Crea un nuovo layout se nessuno è disponibile
                    content = xui.CreatePanel("")
                End If
                Panel1.AddView(content, 0, 0, Panel1.Width, Panel1.Height)
                Panel1.LoadLayout("clv_SingleUser") ' Carica il layout
                ' Popola i campi
               
                edtname.Text = tdettagli.usrName
                edtSurname.Text = tdettagli.usrSurname
                edtBadge.Text = tdettagli.badge
                edtJDE.Text = tdettagli.usrJDE
               
                If cmbCompany.Size = 0 Then cmbCompany.SetItems(lstcompany)
                If cmbDepartement.Size = 0 Then cmbDepartement.SetItems(lstDepartement)
                If cmbLocation.Size = 0 Then cmbLocation.SetItems(lstLocation)
                If cmbWorkerty.Size = 0 Then cmbWorkerty.SetItems(lstWorkerty)
               
                ' Seleziona gli indici corretti
                cmbCompany.SelectedIndex = lstcompany.IndexOf(tdettagli.usrCompany)
                cmbDepartement.SelectedIndex = lstDepartement.IndexOf(tdettagli.usrDepartment)
                cmbLocation.SelectedIndex = lstLocation.IndexOf(tdettagli.usrLocation)
                cmbWorkerty.SelectedIndex = lstWorkerty.IndexOf(tdettagli.usrWrkType)
               
            End If
        Else ' Elemento non visibile
            If Panel1.NumberOfViews > 0 Then
                Dim content As B4XView = Panel1.GetView(0)
                content.RemoveViewFromParent ' Rimuovi il layout dal pannello
                Layouts.Add(content) ' Aggiungi il layout alla lista per il riutilizzo
                Panel1.RemoveAllViews ' Svuota il pannello
            End If
        End If
    Next
    ' Rimuove il focus dai campi di testo impostando il focus su un componente generico
    clvUsrLst.AsView.RequestFocus
End SubThere are other ways?
is it possible load faster or better?
			
				Last edited: 
			
		
	
								
								
									
	
								
							
							 
				 
 
		 
 
		 
 
		 
 
		 
 
		