I am using the following code to fill a TableView from a List:
The problems I have are:
The Table does not clear, but appends data
How am I able to increase the Height of the Table?
B4X:
Sub ShowSalesByStoreByRegion
Dim cursor1 As Cursor
Dim txt As String
Dim MySPList As List
MySPList.Initialize
Table1.ClearAll
txt = "SELECT [Group] AS StoreGROUP, [Store] AS STORE, [Line Total] AS LINETOTAL, [Total Sales] AS TOTALSALES, [Budget] AS BUDGET, [Last Year] AS LASTYEAR, [GP %] AS GP, [# Of Trans] AS NUMOFTRANS, [UPT] AS UPT, [AVT] AS AVT, [Ft Count] AS FOOTCOUNT, [My Price] AS MYPRICE FROM tableSP2"
cursor1=SQL1.ExecQuery(txt)
For i=0 To cursor1.RowCount-1
cursor1.Position=i
Dim MY_GROUP As String = cursor1.GetString("StoreGROUP")
Dim MY_STORE As String = cursor1.GetString("STORE")
Dim MY_UPT As String = cursor1.GetString("UPT")
Dim MY_AVT As String = cursor1.GetString("AVT")
Dim MY_MYPRICE As String = cursor1.GetDouble("MYPRICE")
Dim MY_NUMOFTRANS As String = cursor1.GetDouble("NUMOFTRANS")
Dim MY_BUDGET As String = cursor1.GetDouble("BUDGET")
Dim MY_TOTALSALES As String = NumberFormat2(cursor1.GetDouble("TOTALSALES"), 1,2, 2,True)
Dim MY_LASTYEAR As String =cursor1.GetDouble("LASTYEAR")
Dim MY_LINETOTAL As String = cursor1.GetDouble("LINETOTAL")
Dim MY_GP As String = NumberFormat2(cursor1.GetDouble("GP"), 1,2, 2,True)
' Dim MY_PCRATE As String = NumberFormat2(cursor1.GetDouble("PCRATE"), 1,2, 2,True)
Dim MY_FOOTCOUNT As String = cursor1.GetDouble("FOOTCOUNT")
Dim MY_BUDGETPercent As Double = (MY_LINETOTAL / MY_BUDGET) 'PWSaleDetailLineTotal / Budget
Dim MY_GROWTHPercent As Double = (MY_LINETOTAL / MY_LASTYEAR) -1 '(PWSaleDetailLineTotal / LastYear)-1
Dim MY_FcCONPercent As Double = (MY_NUMOFTRANS / MY_FOOTCOUNT) 'NumerofTrans / Foot Counts
Dim MY_PRICEPercent As Double = (MY_MYPRICE / MY_LINETOTAL) 'MyPrice / PWSaleDetailLineTotal
' MySPList.Add(MY_GROUP & TAB & MY_STORE & TAB & MY_TOTALSALES & TAB & MY_BUDGET & TAB & MY_BUDGETPercent & TAB & MY_LASTYEAR & TAB & MY_GROWTHPercent & TAB & MY_GP & TAB & MY_NUMOFTRANS & TAB & MY_UPT & TAB & MY_AVT & TAB & MY_FOOTCOUNT & TAB & MY_FcCONPercent & TAB & MY_MYPRICE & TAB & MY_PRICEPercent)
MySPList.Add(MY_GROUP & MY_STORE & MY_TOTALSALES & MY_BUDGET & MY_BUDGETPercent & MY_LASTYEAR & MY_GROWTHPercent & MY_GP & MY_NUMOFTRANS & MY_UPT & MY_AVT & MY_FOOTCOUNT & MY_FcCONPercent & MY_MYPRICE & MY_PRICEPercent)
Dim tf() As Typeface
tf = Array As Typeface(Typeface.DEFAULT, Typeface.DEFAULT_BOLD, Typeface.DEFAULT, Typeface.DEFAULT_BOLD, Typeface.DEFAULT)
Table1.SetTypeFaces(tf)
Table1.SetHeader(Array As String("Group", "Store", "Total Sales", "Budget", "Budget %", "Last Year", "Growth %", "GP %", "# of Trans", "UPT", "AVT", "Ft Count", "Fc Con %", "My Price", "My Price %"))
Table1.SetColumnsWidths(Array As Int(25%x, 25%x, 25%x, 25%x, 25%x,25%x, 25%x, 25%x, 25%x, 25%x,25%x, 25%x, 25%x, 25%x, 25%x))
For i=0 To MySPList.Size -1
Table1.AddRow(Array As String(MY_GROUP, MY_STORE, MY_TOTALSALES, MY_BUDGET, MY_BUDGETPercent, MY_LASTYEAR, MY_GROWTHPercent, MY_GP, MY_NUMOFTRANS, MY_UPT, MY_AVT, MY_FOOTCOUNT, MY_FcCONPercent, MY_MYPRICE, MY_PRICEPercent))
Next
Next
Table1.Visible = True
End Sub
The problems I have are:
The Table does not clear, but appends data
How am I able to increase the Height of the Table?