Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Try to understand how SimpleTable work, with the creation of an example...
/*
* MAIN
*
*/
import stdlib.components.simpletable
import stdlib.widgets.core
import stdlib.interactions
//initial rows
rows = [ {t2=3}, {t1="orange"}]
//initial values
els = [{f1={t1="test champ 1"} ; f2="test champ 2" }]
/**
* What's a row
*/
type row = { t1 : string } / { t2 : int }
row_to_string(row : row) : string =
match row with
| {~t1} -> t1
| {~t2} -> "Le chiffre est {t2}"
parameters = {show = a -> <>{a}</>;
edit = a -> <>{a}</>;
on_change = _ -> void;
on_edit = -> void;
on_validate = -> void;
parse = a -> {value = a};
default_value = "default";
manually_editable = false}
type state = {Init}
cell_widgets(row : row, table : CSimpleTable.t(string, state, row)) =
tmp = {
html= id, elt -> [IEditable.html(IEditable.default_config, id, parameters, {show}, elt)]
set_value = id, v -> void} : CSimpleTable.Cell.widget(string)
(tmp,WStyler.empty,false)
/**
* We need a configuration
*/
config = CSimpleTable.default_config(row_to_string, cell_widgets)
id = "my_simpletable_id"
callbacks = CSimpleTable.default_callbacks(row -> Option.some(row_to_string(row)))
display = CSimpleTable.default_display(10) //we wanna show 10 lines
@client onready(_) =
Dom.transform([#something <- CSimpleTable.generate_page(CSimpleTable.create(config, id, callbacks, rows, els, display), "test")])
server = Server.one_page_server("test", -> <div id=#something onready={onready}/>)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.