I'm using your jTreeViewExtended library and would like to be able to set and get the records Primary Key value with the TreeItem object.
I see how you've done it in your demo, but I can't get it to correctly format/set the 3 values when building the TreeItems.
Your code:
B4X:
'Latitude (format #LAT|rowid|value)
Dim LatItem As TreeItem
Dim LatValue As String = "#LAT|" & Records.GetString("rowid") & "|" & Records.GetString("Latitude")
LatItem.Initialize("", LatValue)
CityItem.Children.Add(LatItem)
'Longitude (format #LNG|rowid|value)
Dim LongItem As TreeItem
Dim LngValue As String = "#LNG|" & Records.GetString("rowid") & "|" & Records.GetString("Longitude")
LongItem.Initialize("", LngValue)
CityItem.Children.Add(LongItem)
My code:
B4X:
Dim item As TreeItem
item.Initialize("", "#ID|" & rs.GetInt("ID") & "|" & rs.GetString("Name"))
parentItem.Children.Add(item)
My Tree Item display result:
#ID|25|Mark Stuart
What is the correct way to store/set the record ID with the TreeItem but display another fields value for display?
I see from the following code, this converts the 3 segments to what you want displayed.
I tried the _Convert in my app but it still displays as mentioned in Post #1: #ID|25|Mark Stuart
If it works in your demo, I must be missing something.
Any ideas and help would be appreciated.
B4X:
Sub tvCities_Convert(Text As String, IsEditing As Boolean) As String
Log("Convert " & Text & " " & IsEditing)
'If latitude or longitude...
If Text.StartsWith("#L") Then
'Gets the value from the formatted string
Dim LastSep As Int = Text.LastIndexOf("|")
Dim Value As String = Text.SubString(LastSep + 1)
If IsEditing Then
Return Value
Else If Text.StartsWith("#LAT") Then
Return "Lat.: " & Value
Else
Return "Long.: " & Value
End If
End If
Return Text
End Sub