B4J Question [ABMaterial] How to use delete a row in ABMTable

alwaysbusy

Expert
Licensed User
Longtime User
You can't. You could use an ABMTableMutable instead if you do not need it to be scrollable (it can't have both). ABMTableMutable is an alternative for the ABMTable (it is 90% compatible). It can do stuff like InsertRowBefore() and RemoveRow().

All methods have to be changed to use UniqueId as string everywhere instead of row as integer.

e.g. in:

B4X:
UseCellTheme(UniqueId as String, Column as Integer, ThemeName as String)
GetCellTheme(UniqueId as String, Column as Integer) as String
SetCellTag(UniqueId as String, Column as Integer, Tag as Object)
GetCellTag(UniqueId as String, Column as Integer) as Object
GetComponent(UniqueId as String, String componentId) as ABMComponent
SetString(UniqueId as String, Column as Integer, Value as String)
GetString(UniqueId as String, Column as Integer) as String

ABMTableCell as used in event Table_Clicked(PassedRowsAndColumns As List) has a also a row 'Uniqueid'

Usage:

B4X:
  ' create the TableItemProduced1 table
   Dim TableItemProduced1 As ABMTableMutable
  
   TableItemProduced1.Initialize(page, "TableItemProduced1", False, False, True, "tbltheme")
   'TableItemProduced1.IsResponsive = True

   TableItemProduced1.SetHeaders(  Array As String ("regID",page.XTR("0002","Date"),page.XTR("0003","Person"),page.XTR("0004","Client")  ,page.XTR("0005","Article")  ,page.XTR("0006","Number")  ,page.XTR("0007","Edit")  ,page.XTR("0008","Delete")))
   TableItemProduced1.SetHeaderThemes(  Array As String (""  ,""  ,""  ,""  ,""  ,""  ,"hc"  ,"hc"  ))
   TableItemProduced1.SetHeaderHeights(  Array As Int  (0  ,0  ,0  ,0  ,0  ,0  ,0  ,0  ))
   TableItemProduced1.SetColumnWidths(  Array As Int  (0  ,0  ,0  ,0  ,0  ,0  ,70  ,70  ))
   TableItemProduced1.SetColumnVisible(  Array As Boolean(False  ,True  ,True  ,True  ,True  ,True  ,True  ,True  ))
   TableItemProduced1.SetColumnSortable(  Array As Boolean(False  ,False ,False  ,False  ,False  ,False  ,False  ,False  ))
   TableItemProduced1.SetColumnDataFields(Array As String (""  ,""  ,""  ,""  ,""  ,""  ,""  ,""  ))
   TableItemProduced1.SetFooter(page.XTR("0009","Number added: 0"), 12,"")
     
   page.CellR(2,1).AddComponent(TableItemProduced1)

   ...

' later you can then use
Sub TableItemProduced1_Clicked(PassedRowsAndColumns As List)
   Dim tblCellInfo As ABMTableCell = PassedRowsAndColumns.Get(0)
   Dim TableItemProduced1 As ABMTableMutable = page.Component(tblCellInfo.TableName)
  
   ActiveRowUniqueId =  tblCellInfo.RowUniqueID

   TableItemProduced1.RemoveRow(ActiveRowUniqueId)
   ...
End Sub
 
Upvote 0
Top