B4J Question [SOLVED] How To Get Precise B4XTable Column Numbers

cklester

Well-Known Member
Licensed User
Check out the attached simple B4XTable app.

The numbers in each column come from the same source, but they are often displayed as two wildly different numbers!

Can anybody explain why, and how I can make sure that any numbers I display with COLUMN_TYPE_NUMBERS are as precise as can be?

I'm not sure if it's the MyNumberString.As(Float) that is problematic, or B4XTable munging the numbers.

Who knows?


This has been resolved with the use of a column formatter (B4XFormatter). Check out the attached app to see how it works.

There's also a random number generator that gets you anything from "0.0" to "999999999.999999999." It's handy for testing purposes. (Might could be made faster, but it's already fast enough.)
 

Attachments

  • b4xtable_column_formats_test_final.zip
    9.7 KB · Views: 145
Last edited:

LucaMs

Expert
Licensed User
Longtime User
???:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")

    B4XTable1.AddColumn("Text",B4XTable1.COLUMN_TYPE_TEXT)

    Dim formatter As B4XFormatter
    formatter.Initialize
    formatter.GetDefaultFormat.MinimumIntegers = 1
    formatter.GetDefaultFormat.MinimumFractions = 2
    formatter.GetDefaultFormat.MaximumFractions = 2
    B4XTable1.AddColumn("Number",B4XTable1.COLUMN_TYPE_NUMBERS).Formatter = formatter

    Dim allTheRows As List
    allTheRows.Initialize
    Dim Value As Double
    For i = 0 To 19
        Value = Rnd(0, Power(2, 31))
        allTheRows.Add(Array(NumberFormat2(Value,1,3,3,True), Value))
    Next
    B4XTable1.SetData(allTheRows)
End Sub
 
Upvote 0

cklester

Well-Known Member
Licensed User
I'm attaching the final version to the OP. It does everything I need and provides an example for the B4XFormatter.

Feel free to play around with it!
 
Upvote 0
Top