Editable spreadsheet-style table with an fx bar, search, filtering, images, and formulas.
Select cells and edit values in the top bar. API indexes start at zero; formulas use A1, B1 and so on.
39
Public methods
5
B4A tutorials
4
Events
1
set/get pairs
Interactive playground
Web demonstration of look and behavior; the actual controls run in B4A Android.
A1 · fx =B1*C1
A · Product
B · Quantity
C · Price
D · Total
25.00
22.50
10.00
Edit quantity or price to recalculate the total
Sum: 57.50
Built-in formulas and calculations
References use A1, B1, C1... You can also register expressions through SetFormulaFunction. GetValue reads the result and GetFormula returns the expression.
=B1*C1
Multiply quantity by unit price
=SUM(B1:B3)
Sum a range
=AVERAGE(C1:C3)
Average
=MIN(B1:B3)
Minimum
=MAX(B1:B3)
Maximum
=COUNT(B1:B3)
Number of numeric values
=ABS(-25)
Absolute value
Step-by-step B4A tutorials
Integration examples based on the ElevateUI API. Event handlers are declared outside Activity_Create.
Example 1
Editable inventory with calculated totals
When to use it: Inventory, estimates and invoices.
B4A
Sub Globals
Private xui As XUI
Private Editable As UIEditableTable
End Sub
Sub Activity_Create(FirstTime As Boolean)
Editable.Initialize(Me, "Editable")
Editable.AddToParent(Activity, 10dip, 22dip, Activity.Width - 20dip, 390dip)
Editable.AddColumns(Array As String("Producto", "Cantidad", "Precio", "Total"))
Editable.SetColumnType(1, Editable.COLUMN_TYPE_NUMBER)
Editable.SetColumnType(2, Editable.COLUMN_TYPE_DECIMAL)
Editable.AddRow(Array As String("Cacao", "2", "12.50", ""))
Editable.AddRow(Array As String("Café", "3", "7.50", ""))
Editable.SetFormula(3, 0, "=B1*C1")
Editable.SetFormula(3, 1, "=B2*C2")
End Sub
Private Sub Editable_CellClick(Col As Int, Row As Int)
Log("Celda: " & Col & "," & Row & " = " & Editable.GetValue(Col, Row))
End Sub
Example 2
Formulas and custom functions
When to use it: Lab calculations, financial tracking and repeated operations.
B4A
' Editable ya tiene cuatro columnas y tres filas.
Editable.SetValue(1, 0, "2")
Editable.SetValue(1, 1, "3")
Editable.SetValue(1, 2, "5")
Editable.SetFormula(3, 0, "=SUM(B1:B3)")
Editable.SetFormula(3, 1, "=AVERAGE(B1:B3)")
Dim parametros As List
parametros.Initialize
parametros.Add("x")
Editable.SetFormulaFunction("DOBLE", parametros, "x*2")
Editable.SetFormula(3, 2, "=DOBLE(B3)")
Log(Editable.GetFormula(3, 2))
Log(Editable.GetValue(3, 2))
Example 3
Filters, search and localization
When to use it: Find records quickly in tables with many rows.
B4A
' Ejecutar después de crear Editable y cargar datos.
Editable.Language = "es"
Editable.SetTheme("Ocean")
Editable.SetFilterEnabled(True)
Editable.AddSearchBox
Private Sub Editable_FilterChanged(ActiveFilters As Int)
Log("Filtros activos: " & ActiveFilters)
End Sub
Example 4
Images and controls embedded in cells
When to use it: Product records, order status and laboratory results.
B4A
' producto.png debe estar en Files.
Dim foto As Bitmap = LoadBitmap(File.DirAssets, "producto.png")
Editable.SetHeaderImage(0, foto, 20dip, 20dip)
Editable.SetCellImage(0, 0, foto, 28dip, 28dip)
Dim estado As Label
estado.Initialize("")
estado.Text = "✓"
estado.TextColor = Colors.Green
Editable.AddCellElement(0, 0, estado.As(B4XView), 5dip, 2dip, 26dip, 24dip)
Example 5
Save and restore settings
When to use it: Preserve theme and formula functions between launches.
B4A
Editable.SetTheme("Graphite")
Dim p As List
p.Initialize
p.Add("x")
Editable.SetFormulaFunction("DOBLE", p, "x*2")
Editable.SaveProperties(File.DirInternal, "tabla.map")
' En otra sesión, una vez creada Editable:
Editable.LoadProperties(File.DirInternal, "tabla.map")
B4X properties, fields and constants
When matching setX/getX members exist, assign and read X through property syntax.
Language
Paired set/get: read and write using .Language.
Editable.Language = "es"
Dim idioma As String = Editable.Language
setLanguage + getLanguage
Public fields
mBase As B4XView
Main panel
Editable.mBase.Visible = True
Grid As UITable
Underlying UITable grid with its own API
Log(Editable.Grid.TableSize)
Public constants
Name
Value
Purpose
COLUMN_TYPE_TEXT
1
Text
COLUMN_TYPE_NUMBER
2
Number
COLUMN_TYPE_DECIMAL
3
Decimal
Designer properties
Key
Default
Meaning
Theme
Mint
Initial palette
Mint | Ocean | Violet | Graphite | Rose | Amber | Lagoon | Transparent
FilterEnabled
False
Filter button
Language
Auto
Editor language; Auto follows device
Auto | ar | bn | de | en | es | fr | hi | pt | ru | zh
The four table events
CellClick (Col As Int, Row As Int)
Reports the clicked cell.
Private Sub Editable_CellClick(Col As Int, Row As Int)
Log(Editable.GetValue(Col, Row))
End Sub
ThemeChanged (ThemeName As String)
Fires when the theme is chosen from the toolbar.
Private Sub Editable_ThemeChanged(ThemeName As String)
Log(ThemeName)
End Sub
ColumnDeleted (Col As Int)
Fires when the grid deletes a column.
Private Sub Editable_ColumnDeleted(Col As Int)
Log(Col)
End Sub
FilterChanged (ActiveFilters As Int)
Reports the number of active filter criteria.
Private Sub Editable_FilterChanged(ActiveFilters As Int)
Log(ActiveFilters)
End Sub
Complete public API: 39 methods
Every method retains its exact declaration, explains when it is useful and provides copyable B4A code.
Initialize
Public Sub Initialize(Callback As Object, EventName As String)
Use case: Initialize the table and register its events
B4A
Editable.Initialize(Me, "Editable")
Result: the statement performs the described action on the component.
AddToParent
Public Sub AddToParent(Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
Use case: Place the table within an Activity or a panel
Result: the statement performs the described action on the component.
GetColumnType
Public Sub GetColumnType(Index As Int) As Int
Use case: Read a column's editing keyboard type
B4A
Dim tipo As Int = Editable.GetColumnType(2)
Log(tipo)
Result: the statement performs the described action on the component.
AddSearchBox
Public Sub AddSearchBox
Use case: Open floating search across the entire table
B4A
Editable.AddSearchBox
Result: the statement performs the described action on the component.
DeleteSelectedRow
Public Sub DeleteSelectedRow
Use case: Delete the currently selected row
B4A
Editable.DeleteSelectedRow
Result: the statement performs the described action on the component.
DeleteRow
Public Sub DeleteRow(RowIndex As Int)
Use case: Delete a row by its zero-based index
B4A
Editable.DeleteRow(1)
Result: the statement performs the described action on the component.
AddColumn
Public Sub AddColumn(NewColumnName As String)
Use case: Append a new column
B4A
Editable.AddColumn("Observación")
Result: the statement performs the described action on the component.
AddRow
Public Sub AddRow(Values() As String)
Use case: Append one record
B4A
Editable.AddRow(Array As String("Cacao", "2", "12.50", ""))
Result: the statement performs the described action on the component.
AddEmptyRow
Public Sub AddEmptyRow
Use case: Append one user-editable blank row
B4A
Editable.AddEmptyRow
Result: the statement performs the described action on the component.
AddEmptyRows
Public Sub AddEmptyRows(Count As Int)
Use case: Prepare multiple blank rows
B4A
Editable.AddEmptyRows(5)
Result: the statement performs the described action on the component.
AddRows
Public Sub AddRows(Rows As List)
Use case: Load a batch of rows from a B4A List
B4A
Dim filas As List
filas.Initialize
filas.Add(Array As String("Café", "3", "7.50", ""))
filas.Add(Array As String("Cacao", "2", "12.50", ""))
Editable.AddRows(filas)
Result: the statement performs the described action on the component.
GetValue
Public Sub GetValue(Col As Int, Row As Int) As String
Use case: Read a cell's displayed value
B4A
Dim valor As String = Editable.GetValue(0, 0)
Log(valor)
Result: the statement performs the described action on the component.
SetValue
Public Sub SetValue(Col As Int, Row As Int, Value As String)
Use case: Update a cell value programmatically
B4A
Editable.SetValue(1, 0, "8")
Result: the statement performs the described action on the component.
SetHeaderImage
Public Sub SetHeaderImage(Col As Int, Image As Bitmap, Width As Int, Height As Int)
Use case: Add a bitmap beside a column heading
B4A
Dim bmp As Bitmap = LoadBitmap(File.DirAssets, "producto.png")
Editable.SetHeaderImage(0, bmp, 20dip, 20dip)
Result: the statement performs the described action on the component.
ClearHeaderImage
Public Sub ClearHeaderImage(Col As Int)
Use case: Remove a heading image
B4A
Editable.ClearHeaderImage(0)
Result: the statement performs the described action on the component.
GetCellContentPanel
Public Sub GetCellContentPanel(Col As Int, Row As Int) As B4XView
Use case: Get a cell's transparent overlay panel
B4A
Dim celda As B4XView = Editable.GetCellContentPanel(0, 0)
Log(celda.Width)
Result: the statement performs the described action on the component.
AddCellElement
Public Sub AddCellElement(Col As Int, Row As Int, Element As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)
Use case: Insert custom B4X views inside a cell
B4A
Dim marca As Label
marca.Initialize("")
marca.Text = "✓"
Editable.AddCellElement(0, 0, marca.As(B4XView), 5dip, 3dip, 30dip, 25dip)
Result: the statement performs the described action on the component.
SetCellImage
Public Sub SetCellImage(Col As Int, Row As Int, Image As Bitmap, Width As Int, Height As Int)
Use case: Insert an image into a table cell
B4A
Dim foto As Bitmap = LoadBitmap(File.DirAssets, "cacao.png")
Editable.SetCellImage(0, 0, foto, 28dip, 28dip)
Result: the statement performs the described action on the component.
ClearCellImage
Public Sub ClearCellImage(Col As Int, Row As Int)
Use case: Clear a cell's image
B4A
Editable.ClearCellImage(0, 0)
Result: the statement performs the described action on the component.
ClearCellElements
Public Sub ClearCellElements(Col As Int, Row As Int)
Use case: Remove embedded cell controls
B4A
Editable.ClearCellElements(0, 0)
Result: the statement performs the described action on the component.
SetFormula
Public Sub SetFormula(Col As Int, Row As Int, Formula As String)
Use case: Calculate totals using A1 formulas
B4A
Editable.SetFormula(3, 0, "=B1*C1")
Result: the statement performs the described action on the component.
GetFormula
Public Sub GetFormula(Col As Int, Row As Int) As String
Use case: Read the formula expression rather than computed display
B4A
Dim formula As String = Editable.GetFormula(3, 0)
Log(formula)
Result: the statement performs the described action on the component.
SetFormulaFunction
Public Sub SetFormulaFunction(FunctionName As String, Parameters As List, Expression As String)
Use case: Register a custom arithmetic formula function
B4A
Dim p As List
p.Initialize
p.Add("x")
Editable.SetFormulaFunction("DOBLE", p, "x*2")
Editable.SetFormula(3, 0, "=DOBLE(B1)")
Result: the statement performs the described action on the component.
RemoveFormulaFunction
Public Sub RemoveFormulaFunction(FunctionName As String)
Use case: Remove a registered custom formula function
B4A
Editable.RemoveFormulaFunction("DOBLE")
Result: the statement performs the described action on the component.
GetProperties
Public Sub GetProperties As Map
Use case: Retrieve a copy of saved settings and custom formulas
B4A
Dim config As Map = Editable.GetProperties
Log(config.Get("Theme"))
Result: the statement performs the described action on the component.
SetProperties
Public Sub SetProperties(Properties As Map)
Use case: Restore settings and custom functions from a Map
B4A
Dim config As Map = Editable.GetProperties
config.Put("Theme", "Ocean")
Editable.SetProperties(config)
Result: the statement performs the described action on the component.
SaveProperties
Public Sub SaveProperties(Dir As String, Filename As String)