UI.Table

From GiderosMobile
Revision as of 03:29, 17 October 2023 by MoKaLux (talk | contribs) (Created page with "__NOTOC__ '''Available since:''' Gideros 2023.1<br/> '''Class:''' UI<br/> === Description === Creates a Table widget. <syntaxhighlight lang="lua"> UI.Table.new(columns,di...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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)