B4J Question ABMaterial Table RowuniqueId Empty

walterf25

Expert
Licensed User
Longtime User
Hi All, i need help figuring this out, i am trying to retrieve the RowUniqueId from a table when i click on any of the rows, for some reason the RowUniqueRowId always returns empty, here's my code:
B4X:
Sub tbl1_Clicked(PassedRowsAndColumns As List)
    ' is the root table
    Log("passedrowsandcolumns size: " & PassedRowsAndColumns.Size)
    Dim tblCellInfo As ABMTableCell = PassedRowsAndColumns.Get(0)
    Log("table name: " & tblCellInfo.TableName)
    Log("table row: " & tblCellInfo.Row)
    Log("table uniquerowid: " & tblCellInfo.RowUniqueId)
End  Sub

When I fill the information in the table from a Database i am setting the rowuniqueId to each row as the rowid from the Database, does anyone have any idea why the Rowuniqueid always returns emtpy, is this a bug in the library?

Thanks,
Walter
 

Harris

Expert
Licensed User
Longtime User
Where is your table creation code? Or, importantly, what type of table was created?
Thanks
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Where is your table creation code? Or, importantly, what type of table was created?
Thanks
Here's the code where i create the table, and i am using just the regular
B4X:
public Sub BuildPage()
    ' initialize the theme
    BuildTheme
    
    ' initialize this page using our theme
    page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, ABMShared.SessionMaxInactiveIntervalSeconds, theme)
    page.ShowLoader=True
    page.PageHTMLName = "index.html"
    page.PageTitle = "Parts Inventory"
    page.PageDescription = "Parts Inventory"
    page.PageKeywords = ""
    page.PageSiteMapPriority = ""
    page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_YEARLY
        
    page.ShowConnectedIndicator = True       
    ' adding a navigation bar
    ABMShared.BuildNavigationBar(page, "Parts Inventory","../images/snap.png", "", "", "")   
            
    ' create the page grid
    page.AddRowsM(5,True,0,0, "").AddCells12MPV(12,0,0,0,0,"","")   
    page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    ''page.Cell(1,6).AddComponent(ABMShared.BuildHeader(page, "hdr1", "Welcome to ABMaterial2!"))
    ''page.Cell(1,6).UseTheme("header")
    ''page.Cell(2,3).AddComponent(ABMShared.BuildParagraph(page, "pgr1", "This is a paragraph"))
    
    
    ''Dim btntext As String
    ''If tabs.GetActive =
    
    Dim searchcont As ABMContainer
    Dim searchbox As ABMInput
    
    searchbox.Initialize(page, "searchbox", ABM.INPUT_SEARCH, "Search....", False, "input")
    searchcont.Initialize(page, "searchcont", "")
    btnsearch.InitializeRaised(page, "btnsearch", "mdi-action-search", ABM.ICONALIGN_CENTER, "Search Equip.", "button")
    btnsearch.Size = ABM.BUTTONSIZE_LARGE
    searchcont.AddRows(3, True, "").AddCellsOS(6,3,3,3,6,4,4,"")
    searchcont.BuildGrid
    
    searchcont.Cell(2,2).AddComponent(searchbox)
    searchcont.Cell(3,3).AddComponent(btnsearch)
    
    page.Cell(1,1).AddComponent(searchcont)
    
    Dim tabs As ABMTabs
    tabs.Initialize2(page, "tabs", 48,-8, 8, "tabs")
    
    ' create the tabs as ABMContainers
    Dim cont As ABMContainer = BuildTabContainer("tab1", "{NBSP}Demo tab text TAB1")
    Dim cont2 As ABMContainer = BuildTabContainer("tab2", "")
    
    cont2.Initialize(page, "tblcont","tabpagewhite")
    
    cont2.AddRows(1,True, "").AddCells12(1,"")
    cont2.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    Dim tbl1 As ABMTable
    ''tbl1.Initialize(page, "tbl1", True, False, True, "tbl1theme")
    Dim widths As List
    widths.Initialize
    ''For i = 0 To 6
    widths.Add(130)
    widths.Add(140)
    widths.Add(140)
    widths.Add(150)
    widths.Add(130)
    widths.Add(130)
    widths.Add(130)
    ''Next
    ''tbl1.InitializeScrollable(page, "tbl1", True, False, True, widths, "tbl1theme")
    tbl1.Initialize(page, "tbl1", True, False, True, "tbl1theme")
    tbl1.SetColumnWidths(widths)
    tbl1.IsScrollable = True
    tbl1.SetHeaders(Array As String("Type", "Model", "Serial No", "Owner", "Location", "Cal Due Date", "Actions"))
    tbl1.SetColumnDataFields(Array As String("Type", "Model", "Serial No", "Owner", "Location", "Cal Due Date", "Actions"))
    tbl1.SetHeaderThemes(Array As String("headerfooter", "headerfooter", "headerfooter", "headerfooter", "headerfooter", "headerfooter", "headerfooter"))
    
    If DBM.GetSQL.IsInitialized Then
    Dim sql As SQL
    sql = DBM.GetSQL
    Else
    DBM.InitializeSQLite(File.DirApp, "LabInventory.db", False)
        sql = DBM.GetSQL
    End If
    
    Dim rs As ResultSet
    rs = sql.ExecQuery("SELECT rowid, Type, Model, SerialNo, Owner, Location, CalibrationDue FROM Equipment")
    
    Dim n As Int = 0

    Do While rs.NextRow
        Dim cols As List
        Dim rCellThemes As List
        rCellThemes.Initialize
        cols.Initialize
        n = n + 1
        If n Mod 2 = 0 Then
        cols.Add(rs.GetString("Type"))
        rCellThemes.Add("positive")
        cols.Add(rs.GetString("Model"))
        rCellThemes.Add("positive")
        cols.Add(rs.GetString("SerialNo"))
        rCellThemes.Add("positive")
        cols.Add(rs.GetString("Owner"))
        rCellThemes.Add("positive")
        cols.Add(rs.GetString("Location"))
        rCellThemes.Add("positive")
        cols.Add(rs.GetString("CalibrationDue"))
        rCellThemes.Add("positive")
        Dim update As ABMButton
        update.InitializeRaised(page, "update"&n, "", "", "Update", "")
        cols.Add(update)
        rCellThemes.Add("positive")
        Else
            cols.Add(rs.GetString("Type"))
            rCellThemes.Add("nocolor")
            cols.Add(rs.GetString("Model"))
            rCellThemes.Add("nocolor")
            cols.Add(rs.GetString("SerialNo"))
            rCellThemes.Add("nocolor")
            cols.Add(rs.GetString("Owner"))
            rCellThemes.Add("nocolor")
            cols.Add(rs.GetString("Location"))
            rCellThemes.Add("nocolor")
            cols.Add(rs.GetString("CalibrationDue"))
            rCellThemes.Add("nocolor")
            Dim update As ABMButton
            update.InitializeRaised(page, "update"&n, "", "", "Update", "")
            cols.Add(update)
            rCellThemes.Add("nocolor")
        End If
        
        Log("rowid: " & rs.GetString("rowid"))
        tbl1.AddRow("uid"&rs.GetString("rowid"), cols)
        tbl1.SetCellTag(n-1, 0, rs.GetString("rowid"))
        tbl1.SetRowThemes(rCellThemes)
    Loop
    sql.Close
    Log("column list size: " & cols.Size)
    Log("rcellthemes list size: " & rCellThemes.Size)
    

    
    
    cont2.Cell(1,1).SetFixedHeight(450, True)
    cont2.Cell(1,1).AddComponent(tbl1)
    
    tabs.AddTab("Parts", "EE Parts", cont,3,3,3,12,12,12,True,False, "mdi-hardware-memory", "")
    tabs.AddTab("Equipment", "Equipment Inventory", cont2,3,3,3,12,12,12,True,True, "mdi-action-work", "")
    tabs.AddTab("tab3", "Demo TAB 3 Text", BuildTabContainer("tab3", "{NBSP}Demo tab text TAB3"),3,3,3,12,12,12,True,False, "mdi-editor-insert-comment", "")

    page.Cell(2,1).AddComponent(tabs)
    
End Sub
.
I have figured this part out, what i did is as you can see above in the code, i am setting the rowid number to tag object of the first cell of each row, this works as i can retrieve the tag object in the tbl1_click event.

I just also realized that the following function does not get raised either:
B4X:
Sub tbl1_SortChanged(DataField As String, Order As String)
    Log("datafield: " & DataField)
End Sub

I am wondering if there's actually a bug in the library?

Thanks,
Walter
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
tblCellInfo.RowUniqueId, "I Think", does not apply to ABMTable - only ABMTableMutable...

When using DB tables, use the primary key of the record for your unique ID.
B4X:
    tblUsers.SetHeaders(         Array As String ("ID"  , "Last Name"   , "First Name"    , "Nic Name"    ,"Start Date", "Location"    , "Active" ,"Open/Edit", "Delete"  ))
    tblUsers.SetHeaderThemes(    Array As String ("bgc" ,     "bgc"       ,       "bgc"        ,        "bgc"    ,        "bgc"        ,    "bgc"      ,   "bgc",   "bgc",   "bgc"   ))
    tblUsers.SetColumnVisible(   Array As Boolean(False, True      , True      , True       , True          , True       , True , True , True    ))

"ID" - primary key.
SetColumnVisible - first item is hidden, if you wish..


Most of the stuff you did in the BuildPage should have been done in the ConnectPage Sub...

A clean BuildPage example.
Build the theme, NavBar, page grid and Add Modal Sheets...

B4X:
public Sub BuildPage()
    ' initialize the theme
    BuildTheme
  
    page.InitializeWithTheme(Name, "/ws/" & ABMShared.AppName & "/" & Name, False, ABMShared.SessionMaxInactiveIntervalSeconds, theme)
  
    page.ShowLoader=True
    page.ShowLoaderType=ABM.LOADER_TYPE_MANUAL ' NEW
    page.PageTitle = "CC Watch"
    page.PageDescription = "CC Watch"
    page.PageHTMLName = "index.html"
    page.PageKeywords = ""
    page.PageSiteMapPriority = "0.50"
    page.PageSiteMapFrequency = ABM.SITEMAP_FREQ_MONTHLY
    page.ShowConnectedIndicator = True
  
    ABMShared.BuildNavigationBar(page, "Mobile Users", "../images/logo1.png", "Mobile Users", "", "")
      
    ' create the page grid
    page.AddRowsM(1,True, 10,10, "").AddCells12(1,"")
'    page.AddRows(1,True, "").AddCellsOS(1,0,0,0,10,10,11,"").AddCellsOSMP(1,0,0,0,2,2,1,14,0,0,0,"")
    page.AddRows(1,True, "").AddCellsOSMP(2,0,0,0, 6,6,6,  10, 10, 10,10,"cnter")
    page.AddRows(1,True, "").AddCellsOSMP(1,0,0,0, 4,4,4,  0, 0, 0,0,"cnter").AddCellsOSMP(2,0,0,0, 1,1,1,   20, 0, 0,0,"cnter").AddCellsOSMP(1,0,0,0, 6,6,6,  20, 0, 0,0,"cnter")
  
    page.AddRowsM(6,True,0,0, "").AddCellsOSMP(1,0,0,0, 12,12,12,  0, 0, 0,0,"")
  
    page.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
      
    ' add a modal sheet template to enter user information
    page.AddModalSheetTemplate(BuildInputSheet)

  
End Sub
 
Last edited:
Upvote 0
Top