nnnjjj123
2020-11-17 1b2c1edb61190eeb19f465ff031eaa3b2a1b8dbc
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
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test Grid Common Cases with showHeader: false</title>
        <meta name="viewport" content="width=570">
        <style>
            @import "../../dojo/resources/dojo.css";
            @import "../css/dgrid.css";
            @import "../css/skins/claro.css";
            @import "../../dijit/themes/claro/claro.css";
            
            h2 {
                font-weight: bold;
                padding-bottom: 0.25em;
                clear: both;
            }
            
            .dgrid {
                width: 700px;
            }
            
            #grid .field-col1 {
                width: 100px;
            }
            #grid .field-col2 {
                width: 30%;
            }
            #grid .field-col4 {
                width: 180px;
            }
            
            #scrollgrid .dgrid-cell {
                width: 100px; /* force all columns to have SOME width */
            }
            #scrollgrid .field-col1 {
                width: 500px;
            }
            #scrollgrid .field-col4 {
                width: 300px;
            }
            
            #tree {
                height: 200px;
            }
            #tree .field-bool {
                width: 20%;
            }
            #tree .field-type {
                width: 80px;
            }
            
            #editgrid {
                width: 90%;
            }
            #editgrid .field-date, #editgrid .field-date2 {
                width: 16em;
            }
            #editgrid .field-integer {
                width: 6em;
            }
            #editgrid .field-bool {
                width: 6em;
            }
        </style>
        <script src="../../dojo/dojo.js" 
            data-dojo-config="async: true"></script>
        <script>
            require(["dojo/on",
                "dgrid/List",
                "dgrid/OnDemandGrid",
                "dgrid/Tree",
                "dgrid/Editor",
                "dgrid/Selection",
                "dgrid/Keyboard",
                "dojo/_base/declare",
                "dijit/form/DateTextBox",
                "dijit/form/HorizontalSlider",
                "dijit/form/NumberSpinner",
                "dgrid/test/data/createSyncStore",
                "dgrid/test/data/createHierarchicalStore",
                "dgrid/test/data/genericData",
                "dgrid/test/data/typesData",
                "dgrid/test/data/hierarchicalCountryData",
                "dojo/domReady!"
            ], function(
                on,
                List,
                Grid,
                Tree,
                Editor,
                Selection,
                Keyboard,
                declare,
                DateTextBox,
                Slider,
                NumberSpinner,
                createSyncStore,
                createHierarchicalStore,
                genericData,
                typesData,
                hierarchicalCountryData){
 
                    var StandardGrid = declare([Grid, Selection, Keyboard, Editor, Tree]),
                        testStore = createSyncStore({ data: genericData }),
                        typesStore = createSyncStore({ data: typesData }),
                        testCountryStore = createHierarchicalStore({ data: hierarchicalCountryData }, true);
 
 
                    window.grid = new StandardGrid({
                        collection: testStore,
                        columns: { // you can declare columns as an object hash (key translates to field)
                            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
                    }, "grid");
                    
                    window.scrollgrid = new StandardGrid({
                        collection: testStore,
                        columns: { // same as previous, repeated to keep objects/plugins unique
                            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
                    }, "scrollgrid");
                    
                    window.tree = new StandardGrid({
                        collection: testCountryStore,
                        selectionMode: "single",
                        columns: {
                            name: {label:'Name', sortable: false, renderExpando: true},
                            bool: {label: 'A CheckBox', sortable: false, editor: "checkbox"},
                            type: {label: 'Type', sortable: false},
                            population: 'Population',
                            timezone: 'Timezone'
                        },
                        showHeader: false
                    }, "tree");
                    
                    window.editGrid = new StandardGrid({
                        collection: typesStore,
                        columns: [ // columns specified as array, with field in each item
                            {label: 'A Date', field: 'date', editor: DateTextBox},
                            {label: 'Real Number', field: 'floatNum', editor: Slider},
                            {
                                label: 'Integer',
                                field: 'integer',
                                editor: NumberSpinner,
                                editorArgs: {
                                    style: 'width: 5em;',
                                    constraints: {min: 9, max: 1550, places: 0}
                                }
                            },
                            {
                                label: 'Text editable if checkbox checked + saved',
                                field: 'text',
                                editor: "text",
                                editOn: "dblclick",
                                canEdit: function (object) {
                                    return object.bool;
                                }
                            },
                            {label: 'Non editable text', field: 'text', sortable: false},
                            {label: 'Another Date', field: 'date2', editor: DateTextBox, editOn: "focus"},
                            {label: 'CheckBox', field: 'bool', editor: "checkbox"}
                        ],
                        selectionMode: "single",
                        showHeader: false
                    }, "editgrid");
                });
        </script>
    </head>
    <body class="claro">
        <h1>Headerless Grid Tests</h1>
        <h2>A basic grid</h2>
        <div id="grid"></div>
        <h2>A grid with a tree column</h2>
        <div tabIndex="2" id="tree"></div>
        <div tabIndex="1" id="list"></div>
        <h2>Same as basic grid, but with column widths exceeding grid width</h2>
        <p>(for testing that nodes occupy correct widths - pay attention to hover/selection style)</p>
        <div id="scrollgrid"></div>
        <h2>Editor Grid</h2>
        <div id="editgrid"></div><br>
    </body>
</html>