Mercurial > urweb
comparison demo/more/grid1.ur @ 915:5e8b6fa5b48f
Start 'more' demo with dbgrid
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Tue, 08 Sep 2009 07:48:57 -0400 |
parents | |
children | 0a91c6ee7eec |
comparison
equal
deleted
inserted
replaced
914:782f0b4eea67 | 915:5e8b6fa5b48f |
---|---|
1 open Dbgrid | |
2 | |
3 table t1 : {Id : int, A : string} | |
4 PRIMARY KEY Id | |
5 | |
6 sequence s | |
7 table t : {Id : int, A : int, B : string, C : bool, D : int} | |
8 PRIMARY KEY Id, | |
9 CONSTRAINT Foreign FOREIGN KEY (D) REFERENCES t1(Id) ON DELETE CASCADE | |
10 | |
11 fun page (n, s) = return <xml>A = {[n]}, B = {[s]}</xml> | |
12 | |
13 open Make(struct | |
14 val tab = t | |
15 con key = [Id = _] | |
16 | |
17 val raw = {Id = {New = nextval s, | |
18 Inj = _}, | |
19 A = {New = return 0, | |
20 Inj = _}, | |
21 B = {New = return "", | |
22 Inj = _}, | |
23 C = {New = return False, | |
24 Inj = _}, | |
25 D = {New = return 0, | |
26 Inj = _}} | |
27 | |
28 structure F = Direct.Foreign(struct | |
29 con nm = #Id | |
30 val tab = t1 | |
31 fun render r = r.A | |
32 end) | |
33 | |
34 val cols = {Id = Direct.readOnly [#Id] ! "Id" Direct.int, | |
35 A = Direct.editable [#A] ! "A" Direct.int, | |
36 B = Direct.editable [#B] ! "B" Direct.string, | |
37 C = Direct.editable [#C] ! "C" Direct.bool, | |
38 D = Direct.editable [#D] ! "D" F.meta, | |
39 DA = computed "2A" (fn r => 2 * r.A), | |
40 Link = computedHtml "Link" (fn r => <xml><a link={page (r.A, r.B)}>Go</a></xml>)} | |
41 end) | |
42 | |
43 fun main () = | |
44 grid <- grid; | |
45 return <xml> | |
46 <head> | |
47 <link rel="stylesheet" type="text/css" href="/defun/grid.css"/> | |
48 </head> | |
49 <body onload={sync grid}> | |
50 {render grid} | |
51 </body> | |
52 </xml> |