Android Question [Solved] How should I use a smart string literal in this case?

Sergio Castellari

Active Member
Licensed User
Filtering= "${Col_ENE_act.SQLID} > 0 or ${Col_AGU_act.SQLID} > 0"
B4XTable1.CreateDataView($" & Filtering & "$)

It didn't work!

Note: "Filtering" may change (depending on filtering options)
 

Sergio Castellari

Active Member
Licensed User
Based on @Erel's explanation, more tests and trials, I found out how I can dynamically filter !!! Basically the names of the temporary fields are cnnn, and from there you can build the corresponding where.
This way it worked as intended!

B4X:
Sub B4XSwitch1_ValueChanged (Value As Boolean)
    If Value Then
        cFiltroSIN ="c7 > 0 or c13 > 0"
    Else
        cFiltroSIN = ""
    End If
    Filtrar
End Sub

Private Sub B4XComboBox1_SelectedIndexChanged (Index As Int)
    cFiltroTE = B4XComboBox1.cmbBox.GetItem(Index).SubString2(0,2)
    Filtrar
End Sub

Private Sub Filtrar
    Dim cFiltrar = "" As String
    If cFiltroSIN = "" And cFiltroTE = "00" Then
        B4XTable1.ClearDataView
        Log("Quito Filtrado")       
    Else
        If cFiltroTE <> "00" Then
            cFiltrar = cFiltrar & " c20 = " & cFiltroTE
        End If
        If cFiltroSIN <> "" Then
            If cFiltroTE <> "00" Then
                cFiltrar = cFiltrar & " and " & cFiltroSIN
            Else
                cFiltrar = cFiltroSIN
            End If
        End If
        B4XTable1.CreateDataView(cFiltrar)
    End If
End Sub

Total hugs (virtual)
 
Upvote 0
Top