B4J Question [ABMaterial] Get values from all cells of ABMTable

Dianzoa

Active Member
Licensed User
Hello.
I need to get the values from every cell or column of an specific row.
Any Help, I tried the ABMTableCell, but that only gives me and specific cell that was clicked, and not other columns of the same row.
 

Harris

Expert
Licensed User
Longtime User
Hummm,

This is elementary...
Have you gone thru the tutorial? (ABM for Dummies)?

Show us your code so we can see where you may have tripped up...
And Please use Code Tags - or reap the wrath of Erel, myself and many others for not doing so.... Just a hint of caution.
 
Last edited:
Upvote 0

Dianzoa

Active Member
Licensed User
Sorry, didn't notice I was on B4A forum-
Harris, for me it's not elementary, it seems to be, but If the creator offers me not a method or function I can't use, I can not do nothing about it. I followed the tutorial and only shows how to get a singular value from an specific cell, not a whole row and their columns values.

B4X:
Sub rep_Clicked(PassedRowsAndColumns As List)
    ' is the root table
    Dim cell_idcliente As ABMTableCell = PassedRowsAndColumns.Get(0)

end sub
That only get the actual index of the row. I tried get(1) but of course is out of boundaries.
 
Upvote 0

Dianzoa

Active Member
Licensed User
I aso tried this, it suppose to get the value of (row,column), but I only get an empty string.
Rep is the ABMTable
B4X:
nombre = rep.GetString(cell_idcliente.row,1)
 
Last edited:
Upvote 0

Harris

Expert
Licensed User
Longtime User
Ok, I feel your pain... It is not so elementary - until shown..

Here is the table created (tbldetl) that we want to get data from the "Clicked" row - and its' columns...

B4X:
    tbldetl.Initialize(page, "tbldetl",   False,  True, True, "tbltheme")
    tbldetl.SetHeaders(         Array As String( "ITEM ID"  ,"Grp","Detail Name", "Help / Description" , "Type", "Edit " ,"Delete"  ))
    tbldetl.SetHeaderThemes(    Array As String(  "bgb" , "bgc", "bgc"    , "bgc"      , "bgc"  , "bgc"  ,"bgc"          ))
    tbldetl.SetColumnVisible(    Array As Boolean( True,  False    , True,   True,       False,  True   ,True     ))

Now, when clicked a selected row, we determine what the values are:


B4X:
 Sub tbldetl_clicked(PassedRowsAndColumns As List)
    
    Dim tblCellInfo As ABMTableCell = PassedRowsAndColumns.Get(0)  ' there is only 1 item in this list - hence Get(0)
    Dim tblCases As ABMTable = page.Component(tblCellInfo.TableName)  ' let's get the ABMtable from the page by getting the cellinfo table name
    SelectedRowId = tblCases.GetString(tblCellInfo.Row,  4)   ' from the row that was selected - get the value of column 4
    'Dim zonenum = tblCases.GetString(tblCellInfo.Row,  1)  ' we could also get the value from column 1 - if we wanted to...
    
' we placed buttons in col 5 & 6 of this table
' was either one of the buttons pressed as part of selecting this table row???

If tblCellInfo.Column = 6 Or tblCellInfo.Column = 5 Then ' edit / delete
    
        If Mastcomp = "0" Then
             Toast(" MASTER TEMPLATE - Make A New Inspection to Modify!",5000)
            Return
        End If

        If tblCellInfo.Column = 5 Then
            ABMGentiInsp_deTEdit(SelectedRowId)   ' this will call the modal sheet so we may edit values...  
    '        Toast("edit this item: "&SelectedRowId,3000)
        End If
        
        
        If tblCellInfo.Column = 6 Then
            ABMGentiInsp_deTDelete(SelectedRowId)
        '    Toast("delete this item: "&SelectedRowId,3000)
         End If   

  End If   
End Sub

Hopefully some of this makes it a bit clearer...

Thanks
 
Upvote 0

Dianzoa

Active Member
Licensed User
This is how I do, and get an empty string, that really work for You?. Maybe I need to get the instance of the table, and NOT just use my global table variable?
I will try now.
 
Upvote 0

Dianzoa

Active Member
Licensed User
This returns empty sgtring ALWAYS, no matter what row it is, of course there is a real value in the column 1
B4X:
Sub tbldetl_clicked(PassedRowsAndColumns As List)
    
    Dim tblCellInfo As ABMTableCell = PassedRowsAndColumns.Get(0)  ' there is only 1 item in this list - hence Get(0)
    Dim tblCases As ABMTable = page.Component(tblCellInfo.TableName)  ' let's get the ABMtable from the page by getting the cellinfo table name
    SelectedRowId = tblCases.GetString(tblCellInfo.Row,  4)   ' from the row that was selected - get the value of column 4
    'Dim zonenum = tblCases.GetString(tblCellInfo.Row,  1)  ' we could also get the value from column 1 - if we wanted to...
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
That's my example code - where is yours? We have no idea what you are trying to accomplish...

Post the code from the entire page you are working with, or Export (project) as Zip...

Thanks
 
Upvote 0

Dianzoa

Active Member
Licensed User
That's my example code - where is yours? We have no idea what you are trying to accomplish...

Post the code from the entire page you are working with, or Export (project) as Zip...

Thanks
This IS the relevant code, rep is the ABMTable, it does not throw an error, but returns ALWAYS an empty string, that's why I asked You, if You really test that code and really works for You?
THis line gets empty always: nombre = tblClientes.GetString(cell_idcliente.row,1)
I am trying to get the full name that is in the column 2, hence 1 in the function which is 0 based. It returns empty string on all columns.
B4X:
Sub rep_Clicked(PassedRowsAndColumns As List)
    ' is the root table
    Dim cell_idcliente As ABMTableCell = PassedRowsAndColumns.Get(0)
 
'    Dim cell_nombre_cliente As ABMTableCell = PassedRowsAndColumns.Get(1)
    'idrepartidor = repar_lista.Get(cell_idcliente.Row)
    Dim s As ABMModalSheet
    s = page.ModalSheet("fixedsheet")
    Dim tblClientes As ABMTable = s.Content.Component("rep")
    'idrepartidor = tblClientes.GetString(cell_idcliente.row,0)
    nombre = tblClientes.GetString(cell_idcliente.row,1)

End Sub
 
Last edited:
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
What Harris means is that you are doing something different that IS NOT shown here in the small snippets you give us to analyze. e.g. it appears to be on a modalsheet not directly on a page (different from the code from Harris, so maybe this has an influence), so how does your creation of the table look like could be helpful. How do you fill the table can help so we don't have to guess what values are in each column. A screenshot of the filled table can help. What is the value of cell_idcliente.row can help.
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
My code works for me of course, - torn from a functional part of my app...

Try this:
B4X:
Sub rep_Clicked(PassedRowsAndColumns As List)

    Dim cell_idcliente As ABMTableCell = PassedRowsAndColumns.Get(0)
    Dim tblClientes As ABMTable = page.Component(tblCellInfo.TableName)
    nombre = tblClientes.GetString(cell_idcliente.row, 1)

    Log(" What is number returned: "&nombre&"   <--- returned anything?")
End Sub

Is rep on the main page or in a modal sheet?
How did you put the nombre in cell 1 of the table? Is it plain text or is it a Label component?

I am getting weary of guessing what you are doing without a complete picture (like the entire page code requested).
You really need to study the dummies tutorial again - since proper ABM coding is covered there in detail - throughout many specific lessons.

Thanks
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
exactly....
 
Upvote 0

Dianzoa

Active Member
Licensed User
Ok! Got it now, I create the table in a fixedsheet like widget. rep is global variable ABMTable. So I initialize at creation of the sheet. Below is the complete code.
B4X:
Sub  BuildFixedFooterSheet() As ABMModalSheet
    Dim myModal As ABMModalSheet
    myModal.Initialize(page, "fixedsheet", True, False, "")
    myModal.Size = ABM.MODALSHEET_SIZE_LARGE
    myModal.Content.UseTheme("modalcontent")
    myModal.Footer.UseTheme("modalfooter")
    myModal.IsDismissible = False

    myModal.Content.AddRows(1,True, "").AddCells12(1,"centre")
'    myModal.Content.AddRows(1,True, "").AddCellsOS(2,0,0,0,6,6,6,"")
'    myModal.Content.AddRows(5,True, "").AddCells12(1,"")
    myModal.Content.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    ' create the grid for the footer
    ' we add a row without the default 20px padding so we need to use AddRowsM().
    myModal.Footer.AddRowsM(1,True,0,0, "").AddCellsOS(1,6,6,6,3,3,3,"").AddCellsOS(1,0,0,0,3,3,3, "")
    myModal.Footer.BuildGrid 'IMPORTANT once you loaded the complete grid AND before you start adding components
    'crear la tabla con los datos de los repartidores.
    rep.Initialize(page,"rep",True,False,True,"")
    rep.SetColumnWidths(Array As Int(75, 200))
    
    rep.IsScrollable = True
    'repartidores.InitializeScrollable(page, "repartidores", True, False, True, Array As Int(75, 300,200,150), "tbl1theme")
    rep.SetHeaders(Array As String("ID","Nombre"))',"Cant. Repartos"))
    
    rep.SetColumnDataFields(Array As String("idrepartidor", "nombre"))
    
    myModal.Content.Cell(1,1).AddComponent(rep)
    ' create the buttons for the footer
    Dim btn_aceptar As ABMButton
    btn_aceptar.InitializeFlat(page, "btn_aceptar", "", "", "Aceptar", "transparent")
    btn_aceptar.Tag = "aceptar"
    Dim btn_cancelar As ABMButton
    btn_cancelar.InitializeFlat(page, "btn_cancelar", "", "", "Cancelar", "transparent")
    myModal.Footer.Cell(1,2).AddComponent(btn_cancelar)
    myModal.Footer.Cell(1,1).AddComponent(btn_aceptar)
    Return myModal
    
End Sub
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
Well I use label objects to insert each column in the row. So I thing getstring won't work?
Correct...
I found this out by accident.... It seems only plain text returns a value - OTHERWISE it will be empty...
That is why I asked how you populated it - cause you did not show us.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Well I use label objects to insert each column in the row. So I thing getstring won't work?
that is it. No, getstring does not work if you use other ABM components (because it can be anything, an ABMImage, an ABMButton, ...). You first have to grab the ABMLabel using getcomponent() and then take the .text property. If nothing special is needed of the label, it is much easier to just fill it with the string instead of a label. Then you can use getstring.

you will also have to make sure every label has a unique id to do this. It is probably a lot easier to use just strings.
 
Upvote 0

Dianzoa

Active Member
Licensed User
Yes! Anyway, is good that I could find an answer, I will use a component and get the text. Thanks so much for Your time and Harris's time hehe
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…