B4J Question adding row to table converts date string to long

raphipps2002

Active Member
Licensed User
Longtime User
I have a tableview with 9 columns and pass form values to an array of 9 objects as seen in the code below.

sdate is a string and dDate is a long for the tick value. The sDate for for a tablerow element to display a familiar date format (2015-01-01) but I am storing the dDate long value (ticks) in an mysql DB.

However, when I use this - tblCB.Items.Add(Arow) with arow(1) being an sdate (2015-01-01) it displays that element in my table is tick value! cant understand why?

The Log clearly show format as 2015-01-01 but in the table is shows the tick value



B4X:
    Dim Arow(9) As Object
        Dim jo As JavaObject = dtpTransaction
        ' Get the value using the getValue() method
       
        Dim sDate As String = jo.RunMethod("getValue", Null)
        Dim dDate As Long = DateTime.DateParse(sDate)
               
        Arow(0) = "E"
        Arow(1) = sDate
        Arow(2) = cmbPurchases.Value
        Arow(3) = txtCostDesc.Text.ToUpperCase
        Arow(4) = Bank
        Arow(5) = "0"
        Arow(6) = Net
        Arow(7) = VAT
        Arow(8) = False
       
        Log("Expense " & Arow(1))
       
        tblCB.Items.Add(Arow)
       
        Arow(1) = dDate
       
        'The '1' in the array after the "get" is the column number you want to justify (zero based)
        Dim jo As JavaObject = tblCB
        For i = 4 To 8
            jo.RunMethodJO("getColumns",Null).RunMethodJO("get",Array(i)).RunMethod("setStyle",Array("-fx-alignment: CENTER-RIGHT;"))
        Next
 

Roycefer

Well-Known Member
Licensed User
Longtime User
You're assigning to Arow(1) sDate, which is a String. Then you're logging the value of of Arow(1) with Log("Expense " & Arow(1)). Then you're adding all of Arow to the TableView.Items List. Then you're assigning to Arow(1) dDate, which is a Long. This is why you get a Long showing up in your TableView.
 
Upvote 0

raphipps2002

Active Member
Licensed User
Longtime User
Thanks for the reply. But I am adding the row to the table while arow (1) = sdate as string

Following the flow of code, I am re assigning arow with dDate (as long) AFTER adding the tablerow

So why is the table row not adding the string value?
 
Upvote 0

raphipps2002

Active Member
Licensed User
Longtime User
How ODD! If I insert

msg.Show("Hello","") just to break the flow of code....between


[CODE

]tblCB.Items.Add(Arow)

msg.show("Hello","")

Arow(1) = dDate
[/CODE]

The table updates just fine! I dont quite get this problem!

Richard
 
Upvote 0

MaFu

Well-Known Member
Licensed User
Longtime User
It seems the TableView reads the array values only on visually refresh, but you overwrite Arow(1) before.
If you show the messagebox it works because the message forces the refresh.
 
Upvote 0
Top