Private Sub CreateCategoriesTable As MiniHtml
If App.ctx.ContainsKey("/hx/categories/table") = False Then
Dim table1 As MiniHtml = Table.cls("table table-bordered table-hover rounded small")
Dim thead1 As MiniHtml = Thead.up(table1).cls("table-light")
Th.up(thead1).sty("text-align: right; width: 50px").text("#")
Th.up(thead1).text("Name")
Th.up(thead1).sty("text-align: center; width: 120px").text("Actions")
Tbody.up(table1)
App.ctx.Put("/hx/categories/table", table1)
End If
DB.Open
DB.Table = "tbl_categories"
DB.Columns = Array("id", "category_name")
DB.OrderBy = CreateMap("id": "DESC")
DB.Query
Dim rows As List = DB.Results
DB.Close
Dim table1 As MiniHtml = App.ctx.Get("/hx/categories/table")
Dim tbody1 As MiniHtml = table1.Child(1)
tbody1.Children.Clear ' remove all children
For Each row As Map In rows
Dim tr1 As MiniHtml = CreateCategoriesRow
tr1.Child(0).text2(row.Get("id"))
tr1.Child(1).text2(row.Get("category_name"))
tr1.Child(2).Child(0).attr("hx-get", "/hx/categories/edit/" & row.Get("id"))
tr1.Child(2).Child(1).attr("hx-get", "/hx/categories/delete/" & row.Get("id"))
tr1.up(tbody1)
Next
Return table1
End Sub