annotate demo/more/grid1.ur @ 1657:2b7d3d99dc42

Prevent unifications of 'others' pieces in record summaries, when both pieces contain unification variables (to prevent undesired unifications)
author Adam Chlipala <adam@chlipala.net>
date Thu, 05 Jan 2012 17:10:43 -0500
parents c815dabcfe3c
children edf86cef0dba
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@931 7 table t : {Id : int, A : int, B : string, C : bool, D : int, E : option int, F : 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@932 11 fun page (n, s) = return <xml>A = {[n]}, B = {[s]}</xml>
adamc@915 12
adamc@915 13 open Make(struct
adam@1647 14 structure F = Direct.Foreign(struct
adam@1647 15 con nm = #Id
adam@1647 16 con t = _
adam@1647 17 val tab = t1
adam@1647 18 fun render r = r.A
adam@1647 19 end)
adam@1647 20
adamc@915 21 val tab = t
adamc@915 22 con key = [Id = _]
adam@1647 23 con row = _
adamc@915 24
adamc@915 25 val raw = {Id = {New = nextval s,
adamc@915 26 Inj = _},
adamc@915 27 A = {New = return 0,
adamc@915 28 Inj = _},
adamc@915 29 B = {New = return "",
adamc@915 30 Inj = _},
adamc@915 31 C = {New = return False,
adamc@915 32 Inj = _},
adamc@915 33 D = {New = return 0,
adamc@930 34 Inj = _},
adamc@930 35 E = {New = return None,
adamc@931 36 Inj = _},
adamc@931 37 F = {New = return None,
adamc@915 38 Inj = _}}
adamc@915 39
adamc@1093 40 val cols = {Id = Direct.readOnly [#Id] "Id" Direct.int,
adamc@1093 41 A = Direct.editable [#A] "A" Direct.int,
adamc@1093 42 B = Direct.editable [#B] "B" Direct.string,
adamc@1093 43 C = Direct.editable [#C] "C" Direct.bool,
adamc@1093 44 D = Direct.editable [#D] "D" F.meta,
adamc@1093 45 E = Direct.editable [#E] "E" (Direct.nullable Direct.int),
adamc@1093 46 F = Direct.editable [#F] "F" (Direct.nullable F.meta),
adamc@915 47 DA = computed "2A" (fn r => 2 * r.A),
adamc@932 48 Link = computedHtml "Link" (fn r => <xml><a link={page (r.A, r.B)}>Go</a></xml>)}
adamc@935 49
adamc@937 50 val aggregates = {Dummy1 = {Initial = (),
adamc@937 51 Step = fn _ _ => (),
adamc@937 52 Display = fn _ => <xml/>},
adamc@937 53 Sum = {Initial = 0,
adamc@937 54 Step = fn r n => r.A + n,
adamc@937 55 Display = txt},
adamc@937 56 Dummy2 = {Initial = (),
adamc@937 57 Step = fn _ _ => (),
adamc@940 58 Display = fn _ => <xml/>},
adamc@937 59 And = {Initial = True,
adamc@937 60 Step = fn r b => r.C && b,
adamc@937 61 Display = txt}}
adamc@964 62
adamc@964 63 val pageLength = Some 10
adamc@915 64 end)
adamc@915 65
adamc@915 66 fun main () =
adamc@915 67 grid <- grid;
adamc@940 68 set (showSelection grid) True;
adamc@915 69 return <xml>
adamc@915 70 <head>
adamc@923 71 <link rel="stylesheet" type="text/css" href="../../grid.css"/>
adamc@915 72 </head>
adamc@915 73 <body onload={sync grid}>
adamc@915 74 {render grid}
adamc@940 75 <hr/>
adamc@941 76 <ccheckbox source={showSelection grid}/> Show selection<br/>
adamc@940 77 Selection: <dyn signal={ls <- selection grid;
adamc@940 78 return (List.mapX (fn r => <xml>{[r.Id]}; </xml>) ls)}/>
adamc@915 79 </body>
adamc@915 80 </xml>