B4X Store
ElevateUI · B4A · UITable / XUI

UIEditableTable

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 · ProductB · QuantityC · PriceD · 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 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

NameValuePurpose
COLUMN_TYPE_TEXT1Text
COLUMN_TYPE_NUMBER2Number
COLUMN_TYPE_DECIMAL3Decimal

Designer properties

KeyDefaultMeaning
ThemeMintInitial palette

Mint | Ocean | Violet | Graphite | Rose | Amber | Lagoon | Transparent

FilterEnabledFalseFilter button
LanguageAutoEditor 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

B4A
Editable.AddToParent(Activity, 10dip, 30dip, Activity.Width - 20dip, 370dip)

Result: the statement performs the described action on the component.

AddToView

Public Sub AddToView(Parent As B4XView, Left As Int, Top As Int, Width As Int, Height As Int)

Use case: Add the table through its equivalent helper

B4A
Editable.AddToView(Activity, 10dip, 30dip, Activity.Width - 20dip, 370dip)

Result: the statement performs the described action on the component.

DesignerCreateView

Public Sub DesignerCreateView(Base As Object, Lbl As Label, Props As Map)

Use case: Automatically invoked by B4A on layout load

B4A
Activity.LoadLayout("Main")
' DesignerCreateView se ejecuta automáticamente

Result: the statement performs the described action on the component.

setLanguage

Public Sub setLanguage(Language As String)

Use case: Choose table menus and controls language

B4A
Editable.Language = "es"

Result: the statement performs the described action on the component.

getLanguage

Public Sub getLanguage As String

Use case: Read the configured language

B4A
Dim idioma As String = Editable.Language
Log(idioma)

Result: the statement performs the described action on the component.

SetFilterEnabled

Public Sub SetFilterEnabled(Enabled As Boolean)

Use case: Enable the editor's toolbar filters

B4A
Editable.SetFilterEnabled(True)

Result: the statement performs the described action on the component.

GetFilterEnabled

Public Sub GetFilterEnabled As Boolean

Use case: Check whether filtering is enabled

B4A
Dim habilitado As Boolean = Editable.GetFilterEnabled
Log(habilitado)

Result: the statement performs the described action on the component.

AddColumns

Public Sub AddColumns(Columns() As String)

Use case: Define headers before adding data

B4A
Editable.AddColumns(Array As String("Producto", "Cantidad", "Precio", "Total"))

Result: the statement performs the described action on the component.

SetColumnType

Public Sub SetColumnType(Index As Int, ColumnType As Int)

Use case: Set numeric or decimal keyboards per column

B4A
Editable.SetColumnType(1, Editable.COLUMN_TYPE_NUMBER)
Editable.SetColumnType(2, Editable.COLUMN_TYPE_DECIMAL)

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)

Use case: Persist settings in a local B4A file

B4A
Editable.SaveProperties(File.DirInternal, "tabla.map")

Result: the statement performs the described action on the component.

LoadProperties

Public Sub LoadProperties(Dir As String, Filename As String)

Use case: Read saved settings on app startup

B4A
Editable.LoadProperties(File.DirInternal, "tabla.map")

Result: the statement performs the described action on the component.

SetTheme

Public Sub SetTheme(ThemeName As String)

Use case: Apply a color theme such as Ocean or Violet

B4A
Editable.SetTheme("Ocean")

Result: the statement performs the described action on the component.

GetThemeNames

Public Sub GetThemeNames As List

Use case: Populate a list of the table's supported themes

B4A
Dim temas As List = Editable.GetThemeNames
For Each nombre As String In temas
    Log(nombre)
Next

Result: the statement performs the described action on the component.

GetBase

Public Sub GetBase As B4XView

Use case: Get the root view for showing or hiding the table

B4A
Editable.GetBase.Visible = True

Result: the statement performs the described action on the component.