jxdnsong
2020-10-23 a7929e6b3ec9ac17233f39e55a2b8ac63ea75f42
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test Programmatic Dijit Layout</title>
        <meta name="viewport" content="width=570">
        <style>
            @import "../../dijit/themes/claro/document.css";
            @import "../css/dgrid.css";
            @import "../../dijit/themes/claro/claro.css";
            @import "../css/skins/claro.css";
            html, body {
                padding: 0;
                margin: 0;
                width: 100%;
                height: 100%;
            }
            #bc {
                height: 100%;
            }
 
            .bcLeft {
                width: 300px;
            }
 
            .dijitDialog {
                width: 500px;
            }
        </style>
        <script src="../../dojo/dojo.js"
            data-dojo-config="async: true"></script>
        <script>
            // callbacks for button clicks
            function showProgContentDialog(){
                dlgProgContent.show();
                //dlgProgContent.content.startup(); //this is a workaround
            }
 
            require(["dgrid/OnDemandGrid",
                "dgrid/Selection",
                "dgrid/extensions/DijitRegistry",
                "dijit/Dialog",
                "dojo/_base/lang",
                "dojo/_base/declare",
                "dijit/layout/BorderContainer",
                "dijit/layout/TabContainer",
                "dijit/Toolbar",
                "dijit/form/Button",
                "dgrid/test/data/testStore",
                "dojo/domReady!"
            ], function(Grid, Selection, DijitRegistry, Dialog, lang, declare, BC, TC, Toolbar, Button, testStore){
 
                var
                    gridCols = window.gridCols = {
                        col1: "Column 1",
                        col2: {name: "Column 2", sortable: false},
                        col3: "Column 3",
                        col4: "Column 4"
                    },
                    CustomGrid = declare([Grid, Selection, DijitRegistry]),
                    gridLeft = new CustomGrid({
                        id: "gridLeft",
                        className: "bcLeft",
                        collection: testStore,
                        columns: lang.clone(gridCols),
                        selectionMode: "single",
                        region: "left",
                        splitter: true
                    }),
                    gridTab1 = new CustomGrid({
                        id: "gridTab1",
                        collection: testStore,
                        columns: lang.clone(gridCols),
                        selectionMode: "single",
                        title: "Tab 1"
                    }),
                    gridTab2 = new CustomGrid({
                        id: "gridTab2",
                        collection: testStore,
                        columns: lang.clone(gridCols),
                        selectionMode: "single",
                        title: "Tab 2"
                    });
 
                var bc = new BC({
                    design: "headline"
                }, "bc");
 
                // Toolbar
                var tb = new Toolbar({
                    id: "tbTop",
                    region: "top"
                });
 
                tb.addChild(new Button ({
                    id: "btnDialog",
                    label: "Programmatic dialog w/ dgrid",
                    onClick: showProgContentDialog
                }));
 
                // TabContainer
                var tc = new TC({
                    id: "tab",
                    "class": "bcCenter",
                    region: "center"
                });
 
                tc.addChild(gridTab1);
                tc.addChild(gridTab2);
 
                bc.addChild(tb);
                bc.addChild(gridLeft);
                bc.addChild(tc);
 
                bc.startup();
 
                // test setting a dgrid as content of a dialog programmatically
                window.dlgProgContent = new Dialog({
                    content: new CustomGrid({
                        id: "gridDlgProgContent",
                        collection: testStore,
                        columns: lang.clone(gridCols),
                        selectionMode: "single"
                    })
                });
            });
        </script>
    </head>
    <body class="claro">
        <div id="bc"></div>
    </body>
</html>