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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" dir="rtl">
    <head>
        <meta charset="utf-8">
        <title>Test Right-To-Left</title>
        <meta name="viewport" content="width=570">
        <style>
            @import "../../dojo/resources/dojo.css";
            @import "../css/dgrid.css";
            @import "../../dijit/themes/claro/claro.css";
            @import "../css/skins/claro.css";
 
            h2 {
                margin: 12px;
            }
            .heading {
                font-weight: bold;
                padding-bottom: 0.25em;
            }
 
            /* also not part of theme, but a contrived example of using dgrid-sortable. */
            .dgrid-sortable {
                font-weight: bold;
            }
 
            /* add styles to size this grid appropriately */
            .dgrid {
                height: 20em;
                margin: 2em;
            }
 
            #scrollgrid {
                width: 700px;
                zoom: 1;
            }
            #scrollgrid .dgrid-cell {
                width: 100px; /* force all columns to have SOME width */
            }
            #scrollgrid .field-col1 {
                width: 500px;
            }
            #scrollgrid .field-col4 {
                width: 300px;
            }
        </style>
        <script src="../../dojo/dojo.js"
            data-dojo-config="async: true"></script>
        <script>
 
            require(["dgrid/Grid", "dgrid/OnDemandGrid","dgrid/Selection", "dgrid/Keyboard",
                    "dgrid/Tree", "dgrid/Editor", "dojo/_base/lang",
                    "dojo/_base/declare", "dojo/on", "dojo/data/ObjectStore",
                    "dojo/store/Memory", "dojo/store/Observable",
                    "dgrid/test/data/createSyncStore", "dgrid/test/data/createHierarchicalStore",
                    "dgrid/test/data/testStore", "dgrid/test/data/stateData", "dgrid/test/data/typesData",
                    "dgrid/test/data/hierarchicalCountryData",
                    "dijit/form/CheckBox", "dijit/form/TimeTextBox",
                    "dijit/form/Select", "dijit/form/FilteringSelect",
                    "dgrid/extensions/Pagination", "dojo/domReady!"],
                function(
                    Grid, OnDemandGrid, Selection, Keyboard, Tree, Editor, lang, declare, on, ObjectStore,
                    LegacyMemory, LegacyObservable, createSyncStore, createHierarchicalStore,
                    testStore, stateData, typesData, hierarchicalCountryData,
                    CheckBox, TimeTextBox, Select,
                    FilteringSelect, Pagination
                ){
                    var columns = [
                        {label: 'Column 1', field: 'col1'},
                        {label: 'Column 2', field: 'col2', sortable: false},
                        {label: 'Column 3', field: 'col3'},
                        {label: 'Column 4', field: 'col4'},
                        {label: 'Column 5', field: 'col5'}
                    ];
                    var StandardGrid = declare([OnDemandGrid, Selection, Keyboard, Editor, Tree]);
 
                    window.grid = new StandardGrid({
                        collection: testStore,
                        columns: lang.clone(columns)
                    }, "grid");
 
                    window.scrollgrid = new StandardGrid({
                        collection: testStore,
                        columns: lang.clone(columns)
                    }, "scrollgrid");
 
                    window.tree = new StandardGrid({
                        className: "dgrid-autoheight",
                        collection: createHierarchicalStore({ data: hierarchicalCountryData }, true),
                        columns: [
                            {label: ' ', field: 'bool', sortable: false, editor: "checkbox"},
                            {label:'Name', field:'name', sortable: false, renderExpando: true},
                            {label:'Type', field:'type', sortable: false},
                            {label:'Population', field:'population'},
                            {label:'Timezone', field:'timezone'}
                        ]
                    }, "tree");
 
                    window.headerless = new StandardGrid({
                        collection: testStore,
                        columns: {
                            col1: {label: 'Column 1 column 1 column 1', editor: "text", editOn: "dblclick"},
                            col2: {label: 'Column 2', sortable: false},
                            col3: {label: 'Column 3', editor: "text", editOn: "dblclick"},
                            col4: 'Column444444444444444444',
                            col5: {label: 'Column 5', editor: "text", editOn: "dblclick"}
                        },
                        showHeader: false
 
                    }, "headerless");
 
                    stateStore = new ObjectStore({
                        objectStore: LegacyObservable(new LegacyMemory({ data: lang.clone(stateData) })),
                        labelProperty: "name"
                    });
 
                    window.moreeditors = new StandardGrid({
                        collection: createSyncStore({ data: typesData }),
                        columns: [
                            {field: "id", label: "id"},
                            {
                                label: "CheckBox",
                                field: "bool2",
                                editor: CheckBox,
                                editorArgs: {
                                    value: "checked"
                                }
                            },
                            {
                                label: "Time",
                                field: "date2",
                                editor: TimeTextBox,
                                editorArgs: {
                                    timePattern: "HH:mm:ss",
                                    clickableIncrement: "T00:15:00",
                                    visibleIncrement: "T00:15:00",
                                    visibleRange: "T01:00:00"
                                }
                            },
                            {
                                label: "Select Options",
                                field: "bool",
                                get: function(item){
                                    // return as string to match option in list
                                    return "" + item.bool;
                                },
                                set: function(item){
                                    // convert back to boolean from string
                                    return item.bool == "true";
                                },
                                editor: Select,
                                editOn: "dblclick",
                                editorArgs: {
                                    style: "width:75px;",
                                    options: [
                                        {value: "true", label: "true"},
                                        {value: "false", label: "false"}
                                    ]
                                }
                            },
                            {
                                label: "Select Store",
                                field: "state",
                                editor: Select,
                                editOn: "click",
                                editorArgs: {
                                    store: stateStore,
                                    maxHeight: 150,
                                    style: "width:120px;"
                                }
                            },
                            {
                                label: "FilteringSelect Store",
                                field: "state2",
                                editor: FilteringSelect,
                                editorArgs: {
                                    store: stateStore,
                                    maxHeight: 150,
                                    style: "width:120px;"
                                }
                            }
                        ],
                        selectionMode: "none"
                    }, "moreeditors");
 
                    window.paginationGrid = new declare([Grid, Selection, Keyboard, Pagination])({
                        collection: testStore,
                        columns: lang.clone(columns)
                    }, "pagination");
                });
        </script>
    </head>
    <body class="claro">
        <h2>A basic grid</h2>
        <div id="grid"></div>
 
        <h2>Same as basic grid, but with column widths exceeding grid width</h2>
        <p>(for testing horizontal scrolling)</p>
        <div id="scrollgrid"></div>
 
        <h2>Lazy-loading tree grid with auto-height</h2>
        <div id="tree"></div>
 
        <h2>Headerless grid</h2>
        <div id="headerless"></div>
 
        <h2>Grid with editors</h2>
        <div id="moreeditors"></div>
        <button type="button" id="save" onclick="moreeditors.save()">Save</button>
 
        <h2>A grid with Pagination</h2>
        <div id="pagination"></div>
    </body>
</html>