Hello, thank you for your great job. Please can you implement clv with jrdc(instead of static listview) to populate the drawer item. Please i want such code idea Thanks
Sub LoadSlideMenu
CLVL.Clear
If Main.gLogin = 0 Then
CLVL.Add(CreateMenu(Chr(0xF090), "Log in"), "Log in")
CLVL.Add(CreateMenu(Chr(0xF234), "Register"), "Register")
Else
CLVL.Add(CreateMenu(Chr(0xF05A), "About Me"), "About Me")
CLVL.Add(CreateMenu(Chr(0xF013), "Change Password"), "Change Password")
CLVL.Add(CreateMenu(Chr(0xF08B), "Log out"), "Log out")
End If
End Sub
Private Sub CreateMenu (MenuIcon As String, MenuText As String) As B4XView
Dim Height As Int = 60dip
Dim Width As Int = CLVL.AsView.Width
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("MenuItem")
lblMenuIcon.Text = MenuIcon
lblMenuText.Text = MenuText
Return p
End Sub
The example project is quite old but you can use it as a reference.
Updates: Latest B4XPages user login client apps (using B4J server): https://www.b4x.com/android/forum/threads/project-template-user-login-client-b4x.161914/ Finally I would like to share my B4J API server written in B4J. Compare to my previous PHP API, this API server implements user...
sql.getMenus= SELECT menu FROM B4X.menus WHERE islogin = ?
Client app
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Drawer.Initialize(Me, "Drawer", Root, 400dip)
Drawer.LeftPanel.LoadLayout("LeftMenu")
LoadSlideMenu(1)
End Sub
Sub CreateRequest As DBRequestManager
Dim req As DBRequestManager
req.Initialize(Me, Main.rdcLink)
Return req
End Sub
Sub CreateCommand (Name As String, Parameters() As Object) As DBCommand
Dim command As DBCommand
command.Initialize
command.Name = Name
If Parameters <> Null Then command.Parameters = Parameters
Return command
End Sub
Private Sub CreateMenu(MenuText As String) As B4XView
Dim Height As Int = 60dip
Dim Width As Int = clvLeftMenu.AsView.Width
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("MenuItem")
lblMenu.Text = MenuText
Return p
End Sub
Sub LoadSlideMenu (isLogin As Int)
Dim req As DBRequestManager = CreateRequest
Dim com As DBCommand = CreateCommand("getMenus", Array As Object(isLogin))
Wait For (req.ExecuteQuery(com, 0, Null)) JobDone (job As HttpJob)
If job.Success Then
req.HandleJobAsync(job, "req")
Wait For (req) req_Result (res As DBResult)
'req.PrintTable(res)
clvLeftMenu.Clear
For Each row() As Object In res.Rows
clvLeftMenu.Add(CreateMenu(row(0)), row(0))
Next
Else
xui.MsgboxAsync(job.ErrorMessage, "Error")
End If
job.Release
Log("Left Menu populated")
End Sub
Private Sub clvLeftMenu_ItemClick (Index As Int, Value As Object)
Log(Value)
End Sub
I want to achieve the menuitem as above on the drawer but have nothing at all except the curly brazes,( please don't mind the test labels).
I want to achieve it inside Josejar crud+login code as below
Private Sub CreateSideMenu(MenuText As Object) As B4XView
Dim Height As Int = 60dip
Dim Width As Int = clvLeftMenu.AsView.Width
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, Width, Height)
p.LoadLayout("MenuItemm")
lblMenu.Text = MenuText
Return p
End Sub
Sub LoadSlideMenu (isLogin As Int)
clvLeftMenu.Clear
Dim rs As DBResult
' B4XLoadingIndicator1.Show
Dim Paremeters() As String = Array As String(isLogin) ', B4XPages.MainPage.KVS.Get("id_user"))
Wait For(B4XPages.MainPage.jRDC.GetRecord("getMenus", Paremeters)) Complete (Answer As Map)
If Answer.Get("Success") Then
Dim mapData As Map
' Log(Answer)
rs = Answer.Get("Data")
Log(rs)
For Each row() As Object In rs.Rows
' Dim i As Int = 0
mapData.Initialize
' For Each record As Object In row
' 'We will make a map to pass to B4XPreferencesDialo. The map keys must suit to the db name fields
' 'Construimos un mapa para pasarlo a B4XPreferencesDialog. Las claves del mapa deben coincidir con los nombres de las columnas de la bd
' mapData.Put(rs.Columns.GetKeyAt(i), record)
' i = i + 1
' Next
Dim p As B4XView = CreateSideMenu(mapData)
clvLeftMenu.Add(p, mapData)
Log(p)
Next
Else
xui.MsgboxAsync("There was an error getting the data. Check your server: " & Answer.Get("Error"), "Error")
Log("No data")
End If
' Answer.Release
Log("Left Menu populated")
End Sub
Your question is about Map.
You need to know row() is an array of object.
For menu, usually it is simple that you don't need to use Map.
Otherwise, you need to let us know how you want to build the menu.
Do you want to add fontawesome beside the label and return different value from the label?
You can add more columns to the table.
In the query, select the columns you want.
jRDC2 should return the item array according to the order.
Then construct the Map with key and value.
Thank you for your reply, yes I want to implement the kind of authorized menu for different users( like web menu coming from the server). I want to have edit and delete font awesome icon beside each drawer menuitems