'Static code module
Sub Process_Globals
Public vuetify As VuetifyApp
Public home As VueComponent
Public path As String
Public name As String = "home"
Private banano As BANano
Private VCol1 As VCol
Private VCol2 As VCol
Private VContainer1 As VContainer
Private VRow1 As VRow
Private VueTable1 As VueTable
Private mint As Int
Private id As Int
Private changeint As Int
Private deleteit As Int
End Sub
Sub Initialize
'establish a reference to the app
vuetify = pgIndex.vuetify
'initialize the component
home.Initialize(Me, name)
home.vuetify = vuetify
'make this the start page
home.Path = "/"
path = home.path
'
'build the page html here
banano.LoadLayout(home.Here, "mytable")
'IMPORTANT
VueTable1.ParentComponent = home
home.BindVueTable(VueTable1)
home.SetMounted(Me, "starttimer", Null)
'add this route component to the app
vuetify.AddRoute(home)
End Sub
Sub starttimer
'clear the table
VueTable1.clear
id = 0
mint = home.SetInterval("addmenu", 5000, Null)
changeint = home.SetInterval("changeit", 6000, Null)
deleteit = home.SetInterval("deleteit1", 7000, Null)
End Sub
Sub addmenu
id = id + 1
Dim nr As Map = CreateMap()
nr.Put("id", id)
nr.Put("name", "Frozen Yogurt")
nr.Put("calories", 159)
nr.Put("fat", 6.0)
nr.Put("carbs", 24)
nr.Put("protein", 4.0)
nr.Put("iron", "1%")
VueTable1.AddItem(nr)
'
'get all added records
Dim recs As List = VueTable1.GetData
'how many records do we have
If recs.Size = 5 Then
'stop adding records
home.ClearInterval(mint)
home.ClearInterval(changeint)
home.ClearInterval(deleteit)
End If
End Sub
Sub changeit
'change calories with random number
Dim rndnum As Int = Rnd(0, 250)
VueTable1.UpdateItem("id", id, CreateMap("calories": rndnum))
End Sub
Sub deleteit1
'change calories with random number
Dim rndnum As Int = Rnd(1, 5)
VueTable1.RemoveItem("id", rndnum)
End Sub