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
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>Test Editors in Store-less Grid</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";
            .heading {
                font-weight: bold;
                padding-bottom: 0.25em;
            }
            #grid .field-date, #grid .field-date2 {
                width: 16em;
            }
            #grid .field-integer {
                width: 6em;
            }
            #grid .field-bool {
                width: 6em;
            }
            .dgrid {
                margin: 10px;
            }
        </style>
        <script src="../../dojo/dojo.js"
            data-dojo-config="async: true"></script>
        <script>
            require(["dgrid/Grid", "dgrid/Selection", "dgrid/Keyboard", "dgrid/Editor", "dijit/form/NumberSpinner", "dojo/_base/declare", "dgrid/test/data/typesData", "dojo/domReady!"],
                function(Grid, Selection, Keyboard, Editor, NumberSpinner, declare, typesData){
                    var columns = [
                        {
                            label: 'Integer',
                            field: 'integer',
                            autoSave: true,
                            editor: NumberSpinner,
                            editorArgs: {style: 'width: 5em;', constraints: {min:1,max:1550,places:0}}
                        },
                        {
                            label: 'Text',
                            field: 'text',
                            autoSave: true,
                            editor: "text",
                            editOn: "dblclick"
                        },
                        {
                            label: 'Non editable text',
                            field: 'text',
                            sortable: false
                        }
                    ];
 
                    window.grid = new (declare([Grid, Selection, Keyboard, Editor]))({
                        columns: columns,
                        selectionMode: "single"
                    }, "grid");
                    // use data directly rather than store
                    grid.renderArray(typesData.items);
 
                    grid.on(".field-integer:change", function(event){
                        if(event.value > 100){
                            event.preventDefault();
                            alert("Values above 100 not allowed");
                        }
                    });
                });
 
        </script>
    </head>
    <body class="claro">
        <h2>A basic grid with editors</h2>
        <p>(This test requires dijit to be installed)</p>
        <p>This test uses a grid without a store, including editors with
            <code>autoSave:true</code>, to test editor's usability in regular
            Grid (which lacks a save method / dirty attribute).
        <div id="grid"></div>
    </body>
</html>