summaryrefslogtreecommitdiff
path: root/demo/more/grid1.ur
blob: ea0dcbd5aaf8ee46249307074b8817d04b224d92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
open Dbgrid

table t1 : {Id : int, A : string}
  PRIMARY KEY Id

sequence s
table t : {Id : int, A : int, B : string, C : bool, D : int, E : option int, F : option int}
  PRIMARY KEY Id,
  CONSTRAINT Foreign FOREIGN KEY (D) REFERENCES t1(Id) ON DELETE CASCADE

(*fun page (n, s) = return <xml>A = {[n]}, B = {[s]}</xml>*)

open Make(struct
              val tab = t
              con key = [Id = _]

              val raw = {Id = {New = nextval s,
                               Inj = _},
                         A = {New = return 0,
                              Inj = _},
                         B = {New = return "",
                              Inj = _},
                         C = {New = return False,
                              Inj = _},
                         D = {New = return 0,
                              Inj = _},
                         E = {New = return None,
                              Inj = _},
                         F = {New = return None,
                              Inj = _}}

              structure F = Direct.Foreign(struct
                                               con nm = #Id
                                               val tab = t1
                                               fun render r = r.A
                                           end)

              val cols = {Id = Direct.readOnly [#Id] ! "Id" Direct.int,
                          (*A = Direct.editable [#A] ! "A" Direct.int,
                          B = Direct.editable [#B] ! "B" Direct.string,
                          C = Direct.editable [#C] ! "C" Direct.bool,
                          D = Direct.editable [#D] ! "D" F.meta,*)
                          E = Direct.editable [#E] ! "E" (Direct.nullable Direct.int),
                          F = Direct.editable [#F] ! "F" (Direct.nullable F.meta)(*,
                          DA = computed "2A" (fn r => 2 * r.A),
                          Link = computedHtml "Link" (fn r => <xml><a link={page (r.A, r.B)}>Go</a></xml>)*)}
          end)

fun main () =
    grid <- grid;
    return <xml>
      <head>
        <link rel="stylesheet" type="text/css" href="../../grid.css"/>
      </head>
      <body onload={sync grid}>
        {render grid}
      </body>
    </xml>