lights FAQ Forum github.com/luapower/x-widgets

Web Development
webb
x-widgets

xrowset

Server-side rowsets for nav-based x-widgets


--[[

	Server-side rowsets for nav-based x-widgets.
	Written by Cosmin Apreutesei. Public Domain.

	Properties to set:
		fields           : {field1, ...} field list (required)
		pk               : 'col1 ...'    primary key (required)
		uks              : ['col1 ...',] unique keys (to validate on the client)
		field_attrs      : {col->field}  extra field attributes
		cols             : 'col1 ...'    default visible columns list
		hide_cols        : 'col1 ...'    columns hidden by default
		ro_cols          : 'col1 ...'    read-only columns
		pos_col          : 'col'         pos column for manual ordering of rows
		id_col           : 'col'         id column for tree-building
		parent_col       : 'col'         parent column for tree-building
		name_col         : 'col'         default display_col in lookup rowsets
		tree_col         : 'col'         tree column (the one with [+] icons)
		params           : 'par1 ...'    detail param names for master-detail
		can_add_rows     : f             allow adding new rows
		can_remove_rows  : f             allow removing rows
		can_change_rows  : f             allow editing existing rows

	Field attributes sent to client:
		name             : 'col'         name for use in code
		type             : 'number'|...  client-side type
		text             : 'Foo Bar'     input-box label / grid column header
		hint             : '...'         tooltip
		default          : val           default value (if it's a constant)
		internal         : t             cannot be made visible
		hidden           : t             not visible by default
		readonly         : f             cannot be changed
		enum_values      : ['foo',...]   enum values
		not_null         : t             can't be null
		min              : n             min allowed value
		max              : n             max allowed value
		decimals         : n             number of decimals
		maxlen           : n             max length in characters
		w                : px            default grid column width
		min_w            : px            min grid column width
		max_w            : px            max grid column width
		max_char_w       : n             max grid column width in characters

	Methods to implement:
		- load_rows(result, params)
		- insert_row(vals)
		- update_row(vals)
		- delete_row(vals)
		- load_row(vals)

	Sets by default:
		- `can_[add|change|remove]_rows` are set to false on missing row update methods.
		- `pos_col` and `parent_col` are set to hidden by default.
		- on client-side, `id_col` is set to pk if pk is single-column.

]]

See the source code for more info.


Package:x-widgets
Pkg type:Lua+ffi
Version: 7002cca
Last commit:
License: Public Domain

Requires: errors  fs  glue  luajit  path  time  webb  base64  cjson  connpool  coro  heap  hmac  msgpack  mustache  mysql  pp  queue  schema  sha1  sha2  sock  sqlpp  tarantool  uri  xxhash 

Required by: none


Top