B4J Question [solved] sithasodaisy and search SDUITable

giannimaione

Well-Known Member
Licensed User
Longtime User
hello,
B4X:
Table1 as SDUITable
Table1 hasSearch True
and columns as
Table1.AddColumn ("ABC", "Abc")
Table1.AddColumn ("DEF", "Def")
'function search, find into ALL columns, and it is good!

now Table1 has
B4X:
Table1.AddColumn("idcategorie", "Categoria") 'map categorie
Table1.SetColumnComputeValue("idcategorie", "subCategorie")
'
'
Sub subCategorie (item As Map) As String 'ignore
'
'
'
End Sub
but search NOT find into idcategorie
do I need to configure something?
 

Mashiane

Expert
Licensed User
Longtime User
Computed values are values that are computed at runtime and do not affect the original list passed to the table. This is by design.

I have not tested this, but try this

B4X:
Sub subCategorie (item As Map) As String 'ignore
item.put("idcategorie", "NEW VALUE")
return NEW VALUE
End Sub

Note that updating "idcategorie" in this way might have some unexpected consequences.

What you can do, is to add a fictitious column to the table, so that the original value is not changed and update the value of that column with a value based on the original data.

B4X:
Table1.AddColumn("idcategorie1", "Categoria") 'map categorie
Table1.SetColumnComputeValue("idcategorie1", "subCategorie")
'
'
Sub subCategorie (item As Map) As String 'ignore
dim sidcategorie as string = item.get("idcategorie")
item.put(''idcategorie1'', new_value_based_on_idcategory)
return new_value_based_on_idcategory
'
'
End Sub

This might just work, unfortunately Im not sure about search.
 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
solved,
sorry, my mistake
B4X:
Sub subcategoria (item As Map) As String 'ignore
    Dim categoria As String = item.Get("categoria")
    'Dim stringa As String = mapCategoria.GetDefault(categoria, "") 'bad, my error
    Dim stringa As String = mapCategoria.GetDefault(categoria, categoria) 'ok
    item.Put("categoria", stringa)
    Return stringa
End Sub
 
Upvote 0
Top