annotate demo/more/grid1.ur @ 930:51bc7681c47e
Nullable columns *might* be working, but too much JS is generated for the page to load in finite time
author |
Adam Chlipala <adamc@hcoop.net> |
date |
Sat, 12 Sep 2009 15:08:16 -0400 |
parents |
0a91c6ee7eec |
children |
be6585b4058b |
rev |
line source |
adamc@915
|
1 open Dbgrid
|
adamc@915
|
2
|
adamc@915
|
3 table t1 : {Id : int, A : string}
|
adamc@915
|
4 PRIMARY KEY Id
|
adamc@915
|
5
|
adamc@915
|
6 sequence s
|
adamc@930
|
7 table t : {Id : int, A : int, B : string, C : bool, D : int, E : option int}
|
adamc@915
|
8 PRIMARY KEY Id,
|
adamc@915
|
9 CONSTRAINT Foreign FOREIGN KEY (D) REFERENCES t1(Id) ON DELETE CASCADE
|
adamc@915
|
10
|
adamc@930
|
11 (*fun page (n, s) = return <xml>A = {[n]}, B = {[s]}</xml>*)
|
adamc@915
|
12
|
adamc@915
|
13 open Make(struct
|
adamc@915
|
14 val tab = t
|
adamc@915
|
15 con key = [Id = _]
|
adamc@915
|
16
|
adamc@915
|
17 val raw = {Id = {New = nextval s,
|
adamc@915
|
18 Inj = _},
|
adamc@915
|
19 A = {New = return 0,
|
adamc@915
|
20 Inj = _},
|
adamc@915
|
21 B = {New = return "",
|
adamc@915
|
22 Inj = _},
|
adamc@915
|
23 C = {New = return False,
|
adamc@915
|
24 Inj = _},
|
adamc@915
|
25 D = {New = return 0,
|
adamc@930
|
26 Inj = _},
|
adamc@930
|
27 E = {New = return None,
|
adamc@915
|
28 Inj = _}}
|
adamc@915
|
29
|
adamc@915
|
30 structure F = Direct.Foreign(struct
|
adamc@915
|
31 con nm = #Id
|
adamc@915
|
32 val tab = t1
|
adamc@915
|
33 fun render r = r.A
|
adamc@915
|
34 end)
|
adamc@915
|
35
|
adamc@915
|
36 val cols = {Id = Direct.readOnly [#Id] ! "Id" Direct.int,
|
adamc@915
|
37 A = Direct.editable [#A] ! "A" Direct.int,
|
adamc@915
|
38 B = Direct.editable [#B] ! "B" Direct.string,
|
adamc@930
|
39 C = Direct.editable [#C] ! "C" Direct.bool(*,
|
adamc@915
|
40 D = Direct.editable [#D] ! "D" F.meta,
|
adamc@930
|
41 E = Direct.editable [#E] ! "E" (Direct.nullable Direct.int),
|
adamc@915
|
42 DA = computed "2A" (fn r => 2 * r.A),
|
adamc@930
|
43 Link = computedHtml "Link" (fn r => <xml><a link={page (r.A, r.B)}>Go</a></xml>)*)}
|
adamc@915
|
44 end)
|
adamc@915
|
45
|
adamc@915
|
46 fun main () =
|
adamc@915
|
47 grid <- grid;
|
adamc@915
|
48 return <xml>
|
adamc@915
|
49 <head>
|
adamc@923
|
50 <link rel="stylesheet" type="text/css" href="../../grid.css"/>
|
adamc@915
|
51 </head>
|
adamc@915
|
52 <body onload={sync grid}>
|
adamc@915
|
53 {render grid}
|
adamc@915
|
54 </body>
|
adamc@915
|
55 </xml>
|