UI.Table

From GiderosMobile

Available since: Gideros 2023.1
Class: UI

Description

Creates a Table widget.

UI.Table.new(columns,direction,cellSpacingX,cellSpacingY,fixed)

Parameters

columns: (table) the Table widget columns definition
direction: (bool) is it an horizontal Table widget (default = false)
cellSpacingX: (number) the Table widget cell spacing on the x axis
cellSpacingY: (number) the Table widget cell spacing on the y axis
fixed: (bool) is it a fixed Table widget (if true please provide cellSpacingX and cellSpacingY values) (default = false)

Example

local cols={
	{ name="First name",field="first",weight=2},
	{ name="Last name",field="last",weight=2},
	{ name="Song",field="song",weight=3},
}

local rows = {
	{ first="Paul", last="McCartney", song="Maybe I'm Amazed"},
	{ first="Ringo", last="Starr", song="Photograph"},
	{ first="George", last="Harrison", song="My Sweet Lord"},
	{ first="John", last="Lennon", song="Imagine"},
}

local gui = UI.Table.new(cols, false, 64, 32, true)
gui:setData(table.clone(rows))

--gui:setLayoutConstraints({fill=Sprite.LAYOUT_FILL_HORIZONTAL, anchor=Sprite.LAYOUT_ANCHOR_NORTHWEST})
gui:setDimensions(256, 96)
gui:setColor(0x5c5c5c)
gui:setPosition(50, 50)

gui:setAllowColumnResize(true)
gui:setAllowColumnReorder(true)

local index = #rows+1
table.insert(rows,index,{ first="Pauline", last="Croze", song="Jour de foule"})
gui:setData(table.clone(rows))

local screen=UI.Screen.new() -- needed to add the table
screen:ui(gui)